Refine search
public void abortConnection() throws IOException { if (managedConn != null) { try { managedConn.abortConnection(); } finally { managedConn = null; } } }
if (managedConn.isOpen()) { this.log.debug("Stale connection check"); if (managedConn.isStale()) { this.log.debug("Stale connection detected"); managedConn.close(); if (!managedConn.isOpen()) { managedConn.open(route, context, params); } else { managedConn.setSocketTimeout(HttpConnectionParams.getSoTimeout(params)); managedConn.close(); if (retryHandler.retryRequest(ex, wrapper.getExecCount(), context)) { if (this.log.isInfoEnabled()) { if (!route.isTunnelled()) { this.log.debug("Reopening the direct connection."); managedConn.open(route, context, params); } else { managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS); managedConn.markReusable(); } else { managedConn.close(); managedConn.setState(userToken); managedConn.markReusable();
int step; do { HttpRoute fact = managedConn.getRoute(); step = rowdy.nextStep(route, fact); managedConn.open(route, context, this.params); break; boolean secure = createTunnelToTarget(route, context); this.log.debug("Tunnel to target created."); managedConn.tunnelTarget(secure, this.params); } break; final int hop = fact.getHopCount()-1; // the hop to establish boolean secure = createTunnelToProxy(route, hop, context); this.log.debug("Tunnel to proxy created."); managedConn.tunnelProxy(route.getHopTarget(hop), secure, this.params); } break; managedConn.layerProtocol(context, this.params); break;
public boolean eofDetected(InputStream wrapped) throws IOException { try { if (attemptReuse) { // there may be some cleanup required, such as // reading trailers after the response body: wrapped.close(); managedConn.markReusable(); } } finally { managedConn.releaseConnection(); } return false; }
/** * Shuts down the connection. * This method is called from a {@code catch} block in * {@link #execute execute} during exception handling. */ private void abortConnection() { ManagedClientConnection mcc = managedConn; if (mcc != null) { // we got here as the result of an exception // no response will be returned, release the connection managedConn = null; try { mcc.abortConnection(); } catch (IOException ex) { if (this.log.isDebugEnabled()) { this.log.debug(ex.getMessage(), ex); } } // ensure the connection manager properly releases this connection try { mcc.releaseConnection(); } catch(IOException ignored) { this.log.debug("Error releasing connection", ignored); } } } // abortConnection
public boolean eofDetected(InputStream wrapped) throws IOException { try { if (attemptReuse && (managedConn != null)) { // there may be some cleanup required, such as // reading trailers after the response body: wrapped.close(); managedConn.markReusable(); } } finally { releaseManagedConnection(); } return false; }
public boolean streamClosed(final InputStream wrapped) throws IOException { try { if (managedConn != null) { if (attemptReuse) { final boolean valid = managedConn.isOpen(); // this assumes that closing the stream will // consume the remainder of the response body: try { wrapped.close(); managedConn.markReusable(); } catch (final SocketException ex) { if (valid) { throw ex; } } } else { managedConn.unmarkReusable(); } } } finally { releaseManagedConnection(); } return false; }
throws HttpException, IOException { HttpHost proxy = route.getProxyHost(); HttpHost target = route.getTargetHost(); HttpResponse response = null; if (!this.managedConn.isOpen()) { this.managedConn.open(route, context, this.params); connect); this.requestExec.preProcess(connect, this.httpProcessor, context); response = this.requestExec.execute(connect, this.managedConn, context); this.requestExec.postProcess(response, this.httpProcessor, context); this.managedConn.close(); this.managedConn.close(); throw new TunnelRefusedException("CONNECT refused by proxy: " + response.getStatusLine(), response); this.managedConn.markReusable();
throws HttpException, IOException { Object userToken = context.getAttribute(ClientContext.USER_TOKEN); if (managedConn.isOpen()) { this.log.debug("Stale connection check"); if (managedConn.isStale()) { this.log.debug("Stale connection detected"); managedConn.close(); target = route.getTargetHost(); requestExec.preProcess(wrapper, httpProcessor, context); requestExec.postProcess(response, httpProcessor, context); managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS); managedConn.markReusable(); } else { managedConn.close(); if (proxyAuthState.getState().compareTo(AuthProtocolState.CHALLENGED) > 0 && proxyAuthState.getAuthScheme() != null managedConn.setState(userToken); managedConn.markReusable();
throws HttpException, IOException { HttpHost proxy = route.getProxyHost(); HttpHost target = route.getTargetHost(); HttpResponse response = null; if (!this.managedConn.isOpen()) { this.managedConn.open(route, context, this.params); response = requestExec.execute(connect, this.managedConn, context); context.getAttribute(ClientContext.CREDS_PROVIDER); this.managedConn.close(); this.managedConn.close(); throw new TunnelRefusedException("CONNECT refused by proxy: " + response.getStatusLine(), response); this.managedConn.markReusable();
public Object getUserToken(final HttpContext context) { Principal userPrincipal = null; AuthState targetAuthState = (AuthState) context.getAttribute( ClientContext.TARGET_AUTH_STATE); if (targetAuthState != null) { userPrincipal = getAuthPrincipal(targetAuthState); if (userPrincipal == null) { AuthState proxyAuthState = (AuthState) context.getAttribute( ClientContext.PROXY_AUTH_STATE); userPrincipal = getAuthPrincipal(proxyAuthState); } } if (userPrincipal == null) { ManagedClientConnection conn = (ManagedClientConnection) context.getAttribute( ExecutionContext.HTTP_CONNECTION); if (conn.isOpen()) { SSLSession sslsession = conn.getSSLSession(); if (sslsession != null) { userPrincipal = sslsession.getLocalPrincipal(); } } } return userPrincipal; }
context.setAttribute(ExecutionContext.HTTP_REQUEST, wrapper); if (!managedConn.isOpen()) { managedConn.open(route, context, params); } else { managedConn.setSocketTimeout(HttpConnectionParams.getSoTimeout(params)); } catch (final IOException ex) { try { managedConn.close(); } catch (final IOException ignore) {
HttpRequestExecutor httpexecutor = new HttpRequestExecutor(); context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn); context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, host); context.setAttribute(ClientContext.COOKIE_STORE, cookie_store); if (!conn.isOpen()) { conn.open(route, context, params); httpexecutor.preProcess(request, httpproc, context); response = httpexecutor.execute(request, conn, context); response.setParams(params); httpexecutor.postProcess(response, httpproc, context); System.out.println("=============="); if (!connStrategy.keepAlive(response, context)) { conn.close(); } else { System.out.println("Connection kept alive..."); System.out.println("HttpException"); } finally { conn.close();
if (!managedConn.isOpen()) { if (!route.isTunnelled()) { this.log.debug("Reopening the direct connection."); managedConn.open(route, context, params); } else { this.log.debug("Attempt " + execCount + " to execute request"); response = requestExec.execute(wrapper, managedConn, context); break; this.log.debug("Closing the connection."); try { managedConn.close(); } catch (final IOException ignore) { if (ex instanceof NoHttpResponseException) { final NoHttpResponseException updatedex = new NoHttpResponseException( route.getTargetHost().toHostString() + " failed to respond"); updatedex.setStackTrace(ex.getStackTrace()); throw updatedex;
/** * Releases the connection gracefully. * The connection attribute will be nullified. * Subsequent invocations are no-ops. * * @throws IOException in case of an IO problem. * The connection attribute will be nullified anyway. */ protected void releaseManagedConnection() throws IOException { if (managedConn != null) { try { managedConn.releaseConnection(); } finally { managedConn = null; } } }
@Override public void consumeContent() throws IOException { if (managedConn == null) return; try { if (attemptReuse) { // this will not trigger a callback from EofSensorInputStream wrappedEntity.consumeContent(); managedConn.markReusable(); } } finally { releaseManagedConnection(); } }
public boolean streamClosed(InputStream wrapped) throws IOException { try { if (attemptReuse) { // this assumes that closing the stream will // consume the remainder of the response body: wrapped.close(); managedConn.markReusable(); } } finally { managedConn.releaseConnection(); } return false; }
public boolean streamClosed(InputStream wrapped) throws IOException { try { if (attemptReuse && (managedConn != null)) { // this assumes that closing the stream will // consume the remainder of the response body: wrapped.close(); managedConn.markReusable(); } } finally { releaseManagedConnection(); } return false; }
public boolean streamClosed(final InputStream wrapped) throws IOException { try { if (managedConn != null) { if (attemptReuse) { final boolean valid = managedConn.isOpen(); // this assumes that closing the stream will // consume the remainder of the response body: try { wrapped.close(); managedConn.markReusable(); } catch (final SocketException ex) { if (valid) { throw ex; } } } else { managedConn.unmarkReusable(); } } } finally { releaseManagedConnection(); } return false; }
throws HttpException, IOException { final HttpHost proxy = route.getProxyHost(); final HttpHost target = route.getTargetHost(); HttpResponse response = null; if (!this.managedConn.isOpen()) { this.managedConn.open(route, context, this.params); this.requestExec.preProcess(connect, this.httpProcessor, context); response = this.requestExec.execute(connect, this.managedConn, context); this.requestExec.postProcess(response, this.httpProcessor, context); EntityUtils.consume(entity); } else { this.managedConn.close(); this.managedConn.close(); throw new TunnelRefusedException("CONNECT refused by proxy: " + response.getStatusLine(), response); this.managedConn.markReusable();