mirror of
https://github.com/square/okhttp.git
synced 2026-01-17 08:42:25 +03:00
Merge pull request #2111 from square/jw/route
Drop 'get' prefixed on Route value type.
This commit is contained in:
@@ -172,7 +172,7 @@ public final class ConnectionPoolTest {
|
||||
|
||||
/** Use a helper method so there's no hidden reference remaining on the stack. */
|
||||
private void allocateAndLeakAllocation(ConnectionPool pool, RealConnection connection) {
|
||||
StreamAllocation leak = new StreamAllocation(pool, connection.getRoute().getAddress());
|
||||
StreamAllocation leak = new StreamAllocation(pool, connection.getRoute().address());
|
||||
leak.acquire(connection);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public final class InterceptorTest {
|
||||
|
||||
Interceptor interceptor = new Interceptor() {
|
||||
@Override public Response intercept(Chain chain) throws IOException {
|
||||
Address address = chain.connection().getRoute().getAddress();
|
||||
Address address = chain.connection().getRoute().address();
|
||||
String sameHost = address.url().host();
|
||||
int differentPort = address.url().port() + 1;
|
||||
return chain.proceed(chain.request().newBuilder()
|
||||
|
||||
@@ -331,10 +331,10 @@ public final class RouteSelectorTest {
|
||||
|
||||
private void assertRoute(Route route, Address address, Proxy proxy, InetAddress socketAddress,
|
||||
int socketPort) {
|
||||
assertEquals(address, route.getAddress());
|
||||
assertEquals(proxy, route.getProxy());
|
||||
assertEquals(socketAddress, route.getSocketAddress().getAddress());
|
||||
assertEquals(socketPort, route.getSocketAddress().getPort());
|
||||
assertEquals(address, route.address());
|
||||
assertEquals(proxy, route.proxy());
|
||||
assertEquals(socketAddress, route.socketAddress().getAddress());
|
||||
assertEquals(socketPort, route.socketAddress().getPort());
|
||||
}
|
||||
|
||||
/** Returns an address that's without an SSL socket factory or hostname verifier. */
|
||||
|
||||
@@ -514,7 +514,7 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
|
||||
*/
|
||||
@Override public final boolean usingProxy() {
|
||||
Proxy proxy = route != null
|
||||
? route.getProxy()
|
||||
? route.proxy()
|
||||
: client.getProxy();
|
||||
return proxy != null && proxy.type() != Proxy.Type.DIRECT;
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ public final class ConnectionPool {
|
||||
}
|
||||
|
||||
// We've discovered a leaked allocation. This is an application bug.
|
||||
Internal.logger.warning("A connection to " + connection.getRoute().getAddress().url()
|
||||
Internal.logger.warning("A connection to " + connection.getRoute().address().url()
|
||||
+ " was leaked. Did you forget to close a response body?");
|
||||
references.remove(i);
|
||||
connection.noNewStreams = true;
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class Route {
|
||||
this.inetSocketAddress = inetSocketAddress;
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
public Address address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ public final class Route {
|
||||
* when it is null. When the address's proxy is null, the proxy selector is
|
||||
* used.
|
||||
*/
|
||||
public Proxy getProxy() {
|
||||
public Proxy proxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public InetSocketAddress getSocketAddress() {
|
||||
public InetSocketAddress socketAddress() {
|
||||
return inetSocketAddress;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public final class Http1xStream implements HttpStream {
|
||||
@Override public void writeRequestHeaders(Request request) throws IOException {
|
||||
httpEngine.writingRequestHeaders();
|
||||
String requestLine = RequestLine.get(
|
||||
request, httpEngine.getConnection().getRoute().getProxy().type());
|
||||
request, httpEngine.getConnection().getRoute().proxy().type());
|
||||
writeRequest(request.headers(), requestLine);
|
||||
}
|
||||
|
||||
|
||||
@@ -674,7 +674,7 @@ public final class HttpEngine {
|
||||
|
||||
if (index > 0) {
|
||||
Interceptor caller = client.networkInterceptors().get(index - 1);
|
||||
Address address = connection().getRoute().getAddress();
|
||||
Address address = connection().getRoute().address();
|
||||
|
||||
// Confirm that the interceptor uses the connection we've already prepared.
|
||||
if (!request.url().host().equals(address.url().host())
|
||||
@@ -893,7 +893,7 @@ public final class HttpEngine {
|
||||
? connection.getRoute()
|
||||
: null;
|
||||
Proxy selectedProxy = route != null
|
||||
? route.getProxy()
|
||||
? route.proxy()
|
||||
: client.getProxy();
|
||||
int responseCode = userResponse.code();
|
||||
|
||||
|
||||
@@ -99,10 +99,10 @@ public final class RouteSelector {
|
||||
* failure on a connection returned by this route selector.
|
||||
*/
|
||||
public void connectFailed(Route failedRoute, IOException failure) {
|
||||
if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && address.getProxySelector() != null) {
|
||||
if (failedRoute.proxy().type() != Proxy.Type.DIRECT && address.getProxySelector() != null) {
|
||||
// Tell the proxy selector when we fail to connect on a fresh connection.
|
||||
address.getProxySelector().connectFailed(
|
||||
address.url().uri(), failedRoute.getProxy().address(), failure);
|
||||
address.url().uri(), failedRoute.proxy().address(), failure);
|
||||
}
|
||||
|
||||
routeDatabase.failed(failedRoute);
|
||||
|
||||
@@ -91,10 +91,10 @@ public final class RealConnection implements Connection {
|
||||
|
||||
RouteException routeException = null;
|
||||
ConnectionSpecSelector connectionSpecSelector = new ConnectionSpecSelector(connectionSpecs);
|
||||
Proxy proxy = route.getProxy();
|
||||
Address address = route.getAddress();
|
||||
Proxy proxy = route.proxy();
|
||||
Address address = route.address();
|
||||
|
||||
if (route.getAddress().getSslSocketFactory() == null
|
||||
if (route.address().getSslSocketFactory() == null
|
||||
&& !connectionSpecs.contains(ConnectionSpec.CLEARTEXT)) {
|
||||
throw new RouteException(new UnknownServiceException(
|
||||
"CLEARTEXT communication not supported: " + connectionSpecs));
|
||||
@@ -134,14 +134,14 @@ public final class RealConnection implements Connection {
|
||||
ConnectionSpecSelector connectionSpecSelector) throws IOException {
|
||||
rawSocket.setSoTimeout(readTimeout);
|
||||
try {
|
||||
Platform.get().connectSocket(rawSocket, route.getSocketAddress(), connectTimeout);
|
||||
Platform.get().connectSocket(rawSocket, route.socketAddress(), connectTimeout);
|
||||
} catch (ConnectException e) {
|
||||
throw new ConnectException("Failed to connect to " + route.getSocketAddress());
|
||||
throw new ConnectException("Failed to connect to " + route.socketAddress());
|
||||
}
|
||||
source = Okio.buffer(Okio.source(rawSocket));
|
||||
sink = Okio.buffer(Okio.sink(rawSocket));
|
||||
|
||||
if (route.getAddress().getSslSocketFactory() != null) {
|
||||
if (route.address().getSslSocketFactory() != null) {
|
||||
connectTls(readTimeout, writeTimeout, connectionSpecSelector);
|
||||
} else {
|
||||
protocol = Protocol.HTTP_1_1;
|
||||
@@ -152,7 +152,7 @@ public final class RealConnection implements Connection {
|
||||
socket.setSoTimeout(0); // Framed connection timeouts are set per-stream.
|
||||
|
||||
FramedConnection framedConnection = new FramedConnection.Builder(true)
|
||||
.socket(socket, route.getAddress().url().host(), source, sink)
|
||||
.socket(socket, route.address().url().host(), source, sink)
|
||||
.protocol(protocol)
|
||||
.build();
|
||||
framedConnection.sendConnectionPreface();
|
||||
@@ -168,7 +168,7 @@ public final class RealConnection implements Connection {
|
||||
createTunnel(readTimeout, writeTimeout);
|
||||
}
|
||||
|
||||
Address address = route.getAddress();
|
||||
Address address = route.address();
|
||||
SSLSocketFactory sslSocketFactory = address.getSslSocketFactory();
|
||||
boolean success = false;
|
||||
SSLSocket sslSocket = null;
|
||||
@@ -266,7 +266,7 @@ public final class RealConnection implements Connection {
|
||||
|
||||
case HTTP_PROXY_AUTH:
|
||||
tunnelRequest = OkHeaders.processAuthHeader(
|
||||
route.getAddress().getAuthenticator(), response, route.getProxy());
|
||||
route.address().getAuthenticator(), response, route.proxy());
|
||||
if (tunnelRequest != null) continue;
|
||||
throw new IOException("Failed to authenticate with proxy");
|
||||
|
||||
@@ -286,8 +286,8 @@ public final class RealConnection implements Connection {
|
||||
*/
|
||||
private Request createTunnelRequest() throws IOException {
|
||||
return new Request.Builder()
|
||||
.url(route.getAddress().url())
|
||||
.header("Host", Util.hostHeader(route.getAddress().url()))
|
||||
.url(route.address().url())
|
||||
.header("Host", Util.hostHeader(route.address().url()))
|
||||
.header("Proxy-Connection", "Keep-Alive")
|
||||
.header("User-Agent", Version.userAgent()) // For HTTP/1.0 proxies like Squid.
|
||||
.build();
|
||||
@@ -368,11 +368,11 @@ public final class RealConnection implements Connection {
|
||||
|
||||
@Override public String toString() {
|
||||
return "Connection{"
|
||||
+ route.getAddress().url().host() + ":" + route.getAddress().url().port()
|
||||
+ route.address().url().host() + ":" + route.address().url().port()
|
||||
+ ", proxy="
|
||||
+ route.getProxy()
|
||||
+ route.proxy()
|
||||
+ " hostAddress="
|
||||
+ route.getSocketAddress()
|
||||
+ route.socketAddress()
|
||||
+ " cipherSuite="
|
||||
+ (handshake != null ? handshake.cipherSuite() : "none")
|
||||
+ " protocol="
|
||||
|
||||
Reference in New Issue
Block a user