@Override public void succeeded(SocketChannel channel) { ConnectContext connectContext = new ConnectContext(request, response, asyncContext, (HttpConnection)transport); if (channel.isConnected()) selector.accept(channel, connectContext); else selector.connect(channel, connectContext); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (HttpMethod.CONNECT.is(request.getMethod())) { logger.debug("CONNECT request for {}", request.getRequestURI()); baseRequest.setHandled(true); ConnectContext connectContext = new ConnectContext(request, response, HttpConnection.getCurrentConnection().getEndPoint()); try { SocketChannel channel = SocketChannel.open(); channel.socket().setTcpNoDelay(true); channel.configureBlocking(false); channel.connect(new InetSocketAddress("127.0.0.1", securePort)); selector.connect(channel, connectContext); } catch (IOException ioe) { connectContext.onConnectFailure(ioe); } } else { super.handle(target, baseRequest, request, response); } }
factory.selector.accept(channel, context); else factory.selector.connect(channel, context);
@Override public void succeeded(SocketAddress socketAddress) { SocketChannel channel = null; try { channel = SocketChannel.open(); SocketAddress bindAddress = getBindAddress(); if (bindAddress != null) channel.bind(bindAddress); configure(channel); channel.configureBlocking(false); channel.connect(socketAddress); Future<Connection> futureConnection = new ConnectionCallback(destination, promise); selectorManager.connect(channel, futureConnection); } // Must catch all exceptions, since some like // UnresolvedAddressException are not IOExceptions. catch (Throwable x) { if (channel != null) close(channel); promise.failed(x); } }
@Override public void succeeded(SocketAddress socketAddress) { SocketChannel channel = null; try { channel = SocketChannel.open(); SocketAddress bindAddress = getBindAddress(); if (bindAddress != null) channel.bind(bindAddress); configure(channel); channel.configureBlocking(false); channel.connect(socketAddress); Future<Connection> futureConnection = new ConnectionCallback(destination, promise); selectorManager.connect(channel, futureConnection); } // Must catch all exceptions, since some like // UnresolvedAddressException are not IOExceptions. catch (Throwable x) { if (channel != null) close(channel); promise.failed(x); } }
selectorManager.accept(channel, context); else selectorManager.connect(channel, context);
selector.accept(channel, context); else selector.connect(channel, context);