/** * Cause the socket connection to be released to the connection pool when * it is no longer needed. If it is already unneeded, it will be pooled * immediately. Otherwise the connection is held so that redirects can be * handled by the same connection. */ public final void automaticallyReleaseConnectionToPool() { automaticallyReleaseConnectionToPool = true; if (connection != null && connectionReleased) { client.getConnectionPool().recycle(connection); connection = null; } }
/** * Cause the socket connection to be released to the connection pool when * it is no longer needed. If it is already unneeded, it will be pooled * immediately. Otherwise the connection is held so that redirects can be * handled by the same connection. */ public final void automaticallyReleaseConnectionToPool() { automaticallyReleaseConnectionToPool = true; if (connection != null && connectionReleased) { client.getConnectionPool().recycle(connection); connection = null; } }
/** * Releases this engine so that its resources may be either reused or * closed. Also call {@link #automaticallyReleaseConnectionToPool} unless * the connection will be used to follow a redirect. */ public final void release(boolean streamCancelled) { // If the response body comes from the cache, close it. if (responseBodyIn == cachedResponseBody) { Util.closeQuietly(responseBodyIn); } if (!connectionReleased && connection != null) { connectionReleased = true; if (transport == null || !transport.makeReusable(streamCancelled, requestBodyOut, responseTransferIn)) { Util.closeQuietly(connection); connection = null; } else if (automaticallyReleaseConnectionToPool) { client.getConnectionPool().recycle(connection); connection = null; } } }
/** * Releases this engine so that its resources may be either reused or * closed. Also call {@link #automaticallyReleaseConnectionToPool} unless * the connection will be used to follow a redirect. */ public final void release(boolean streamCancelled) { // If the response body comes from the cache, close it. if (responseBodyIn == cachedResponseBody) { Util.closeQuietly(responseBodyIn); } if (!connectionReleased && connection != null) { connectionReleased = true; if (transport == null || !transport.makeReusable(streamCancelled, requestBodyOut, responseTransferIn)) { Util.closeQuietly(connection); connection = null; } else if (automaticallyReleaseConnectionToPool) { client.getConnectionPool().recycle(connection); connection = null; } } }
hostnameVerifier, client.getAuthenticator(), client.getProxy(), client.getTransports()); routeSelector = new RouteSelector(address, uri, client.getProxySelector(), client.getConnectionPool(), Dns.DEFAULT, client.getRoutesDatabase()); client.getConnectionPool().maybeShare(connection); client.getRoutesDatabase().connected(connection.getRoute()); } else {
hostnameVerifier, client.getAuthenticator(), client.getProxy(), client.getTransports()); routeSelector = new RouteSelector(address, uri, client.getProxySelector(), client.getConnectionPool(), Dns.DEFAULT, client.getRoutesDatabase()); client.getConnectionPool().maybeShare(connection); client.getRoutesDatabase().connected(connection.getRoute()); } else {
sendSocketRequest(); } else if (connection != null) { client.getConnectionPool().recycle(connection); connection = null;
sendSocketRequest(); } else if (connection != null) { client.getConnectionPool().recycle(connection); connection = null;