List of usage examples for org.apache.http.nio.conn ManagedNHttpClientConnection bind
void bind(IOSession iosession);
From source file:org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.java
@Override public void startRoute(final NHttpClientConnection managedConn, final HttpRoute route, final HttpContext context) throws IOException { Args.notNull(managedConn, "Managed connection"); Args.notNull(route, "HTTP route"); final HttpHost host; if (route.getProxyHost() != null) { host = route.getProxyHost();/*from ww w . j av a 2s. c o m*/ } else { host = route.getTargetHost(); } final Lookup<SchemeIOSessionStrategy> reg = getIOSessionFactoryRegistry(context); final SchemeIOSessionStrategy sf = reg.lookup(host.getSchemeName()); if (sf == null) { throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported"); } if (sf.isLayeringRequired()) { synchronized (managedConn) { final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn); final ManagedNHttpClientConnection conn = entry.getConnection(); final IOSession ioSession = conn.getIOSession(); final IOSession currentSession = sf.upgrade(host, ioSession); conn.bind(currentSession); } } }
From source file:org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.java
@Override public void upgrade(final NHttpClientConnection managedConn, final HttpRoute route, final HttpContext context) throws IOException { Args.notNull(managedConn, "Managed connection"); Args.notNull(route, "HTTP route"); final HttpHost host = route.getTargetHost(); final Lookup<SchemeIOSessionStrategy> reg = getIOSessionFactoryRegistry(context); final SchemeIOSessionStrategy sf = reg.lookup(host.getSchemeName()); if (sf == null) { throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported"); }//from ww w. j a v a 2s. c om if (!sf.isLayeringRequired()) { throw new UnsupportedSchemeException( host.getSchemeName() + " protocol does not support connection upgrade"); } synchronized (managedConn) { final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn); final ManagedNHttpClientConnection conn = entry.getConnection(); final IOSession currentSession = sf.upgrade(host, conn.getIOSession()); conn.bind(currentSession); } }