public AsyncDataConsumer handle()

in httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/TerminalAsyncServerFilter.java [70:152]


    public AsyncDataConsumer handle(
            final HttpRequest request,
            final EntityDetails entityDetails,
            final HttpContext context,
            final AsyncFilterChain.ResponseTrigger responseTrigger,
            final AsyncFilterChain chain) throws HttpException, IOException {
        final AsyncServerExchangeHandler exchangeHandler = handlerFactory.create(request, context);
        if (exchangeHandler != null) {
            exchangeHandler.handleRequest(request, entityDetails, new ResponseChannel() {

                @Override
                public void sendInformation(final HttpResponse response, final HttpContext httpContext) throws HttpException, IOException {
                    responseTrigger.sendInformation(response);
                }

                @Override
                public void sendResponse(final HttpResponse response, final EntityDetails entityDetails, final HttpContext httpContext) throws HttpException, IOException {
                    responseTrigger.submitResponse(response, entityDetails != null ? new AsyncEntityProducer() {

                        @Override
                        public void failed(final Exception cause) {
                            exchangeHandler.failed(cause);
                        }

                        @Override
                        public boolean isRepeatable() {
                            return false;
                        }

                        @Override
                        public long getContentLength() {
                            return entityDetails.getContentLength();
                        }

                        @Override
                        public String getContentType() {
                            return entityDetails.getContentType();
                        }

                        @Override
                        public String getContentEncoding() {
                            return entityDetails.getContentEncoding();
                        }

                        @Override
                        public boolean isChunked() {
                            return entityDetails.isChunked();
                        }

                        @Override
                        public Set<String> getTrailerNames() {
                            return entityDetails.getTrailerNames();
                        }

                        @Override
                        public int available() {
                            return exchangeHandler.available();
                        }

                        @Override
                        public void produce(final DataStreamChannel channel) throws IOException {
                            exchangeHandler.produce(channel);
                        }

                        @Override
                        public void releaseResources() {
                            exchangeHandler.releaseResources();
                        }

                    } : null);
                }

                @Override
                public void pushPromise(final HttpRequest promise, final AsyncPushProducer pushProducer, final HttpContext httpContext) throws HttpException, IOException {
                    responseTrigger.pushPromise(promise, pushProducer);
                }

            }, context);
            return exchangeHandler;
        }
        responseTrigger.submitResponse(new BasicHttpResponse(HttpStatus.SC_NOT_FOUND), AsyncEntityProducers.create("Not found"));
        return null;
    }