@Override protected final void handle( final SimpleHttpRequest request, final AsyncServerRequestHandler.ResponseTrigger responseTrigger, final HttpContext context) throws HttpException, IOException { final SimpleHttpResponse response = handle(request, HttpCoreContext.adapt(context)); final SimpleBody body = response.getBody(); final AsyncEntityProducer entityProducer; if (body != null) { if (body.isText()) { entityProducer = new StringAsyncEntityProducer(body.getBodyText(), body.getContentType()); } else { entityProducer = new BasicAsyncEntityProducer(body.getBodyBytes(), body.getContentType()); } } else { entityProducer = null; } responseTrigger.submitResponse(new BasicResponseProducer(response, entityProducer), context); }
@Override public void run() { try { final BasicHttpContext localContext = new BasicHttpContext(); final HttpCoreContext context = HttpCoreContext.adapt(localContext); while (!Thread.interrupted() && this.conn.isOpen()) { this.httpservice.handleRequest(this.conn, context); localContext.clear(); } this.conn.close(); } catch (final Exception ex) { this.exceptionListener.onError(this.conn, ex); } finally { this.conn.close(CloseMode.IMMEDIATE); } }
@Override public void run() { try { final BasicHttpContext localContext = new BasicHttpContext(); final HttpCoreContext context = HttpCoreContext.adapt(localContext); while (!Thread.interrupted() && this.conn.isOpen()) { this.httpservice.handleRequest(this.conn, context); localContext.clear(); } this.conn.close(); } catch (final Exception ex) { this.exceptionListener.onError(this.conn, ex); } finally { this.conn.close(CloseMode.IMMEDIATE); } }
@Override void execute(final RequestExecutionCommand executionCommand) throws HttpException, IOException { final AsyncClientExchangeHandler exchangeHandler = executionCommand.getExchangeHandler(); final HttpCoreContext context = HttpCoreContext.adapt(executionCommand.getContext()); context.setAttribute(HttpCoreContext.SSL_SESSION, getSSLSession()); context.setAttribute(HttpCoreContext.CONNECTION_ENDPOINT, getEndpointDetails()); final ClientHttp1StreamHandler handler = new ClientHttp1StreamHandler( outputChannel, httpProcessor, h1Config, connectionReuseStrategy, exchangeHandler, context); pipeline.add(handler); outgoing = handler; if (handler.isOutputReady()) { handler.produceOutput(); } }
@Override void execute(final RequestExecutionCommand executionCommand) throws HttpException, IOException { final AsyncClientExchangeHandler exchangeHandler = executionCommand.getExchangeHandler(); final HttpCoreContext context = HttpCoreContext.adapt(executionCommand.getContext()); context.setAttribute(HttpCoreContext.SSL_SESSION, getSSLSession()); context.setAttribute(HttpCoreContext.CONNECTION_ENDPOINT, getEndpointDetails()); final ClientHttp1StreamHandler handler = new ClientHttp1StreamHandler( outputChannel, httpProcessor, h1Config, connectionReuseStrategy, exchangeHandler, context); pipeline.add(handler); outgoing = handler; if (handler.isOutputReady()) { handler.produceOutput(); } }
@Override Http2StreamHandler createLocallyInitiatedStream( final ExecutableCommand command, final Http2StreamChannel channel, final HttpProcessor httpProcessor, final BasicHttpConnectionMetrics connMetrics) throws IOException { if (command instanceof RequestExecutionCommand) { final RequestExecutionCommand executionCommand = (RequestExecutionCommand) command; final AsyncClientExchangeHandler exchangeHandler = executionCommand.getExchangeHandler(); final HandlerFactory<AsyncPushConsumer> pushHandlerFactory = executionCommand.getPushHandlerFactory(); final HttpCoreContext context = HttpCoreContext.adapt(executionCommand.getContext()); context.setAttribute(HttpCoreContext.SSL_SESSION, getSSLSession()); context.setAttribute(HttpCoreContext.CONNECTION_ENDPOINT, getEndpointDetails()); return new ClientHttp2StreamHandler(channel, httpProcessor, connMetrics, exchangeHandler, pushHandlerFactory != null ? pushHandlerFactory : this.pushHandlerFactory, context); } throw new H2ConnectionException(H2Error.INTERNAL_ERROR, "Unexpected executable command"); }
response.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE); } else { final HttpCoreContext coreContext = HttpCoreContext.adapt(context); final HttpRequest request = coreContext.getRequest(); boolean closeRequested = false;
response.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE); } else { final HttpCoreContext coreContext = HttpCoreContext.adapt(context); final HttpRequest request = coreContext.getRequest(); boolean closeRequested = false;