@Override protected SelectChannelEndPoint newEndPoint( SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException { // We're connected, cancel the connect timeout Timeout.Task connectTimeout = _connectingChannels.remove(channel); if (connectTimeout != null) connectTimeout.cancel(); if (LOG.isDebugEnabled()) LOG.debug("Channels with connection pending: {}", _connectingChannels.size()); // key should have destination at this point (will be replaced by endpoint after this call) HttpDestination dest = (HttpDestination) key.attachment(); SelectChannelEndPoint scep = new SelectChannelEndPoint(channel, selectSet, key, (int) _httpClient.getIdleTimeout()); AsyncEndPoint ep = scep; if (dest.isSecure()) { LOG.debug("secure to {}, proxied={}", channel, dest.isProxied()); ep = new UpgradableEndPoint(ep, newSslEngine(channel)); } AsyncConnection connection = selectSet.getManager().newConnection(channel, ep, key.attachment()); ep.setConnection(connection); AbstractHttpConnection httpConnection = (AbstractHttpConnection) connection; httpConnection.setDestination(dest); if (dest.isSecure() && !dest.isProxied()) ((UpgradableEndPoint) ep).upgrade(); dest.onNewConnection(httpConnection); return scep; }
@Override protected SelectChannelEndPoint newEndPoint( SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException { SelectChannelEndPoint endp = new SelectChannelEndPoint(channel, selectSet, key, 2000); endp.setConnection(selectSet.getManager().newConnection(channel, endp, key.attachment())); _lastEndp = endp; return endp; }