Search in sources :

Example 46 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class HttpRequestDispatch method handleRequest.

@SuppressWarnings("try")
private ServletRequestReader handleRequest() throws IOException {
    HttpRequest jdiscRequest = HttpRequestFactory.newJDiscRequest(jDiscContext.container, servletRequest);
    ContentChannel requestContentChannel;
    try (ResourceReference ref = References.fromResource(jdiscRequest)) {
        HttpRequestFactory.copyHeaders(servletRequest, jdiscRequest);
        requestContentChannel = requestHandler.handleRequest(jdiscRequest, servletResponseController.responseHandler);
    }
    ServletInputStream servletInputStream = servletRequest.getInputStream();
    ServletRequestReader servletRequestReader = new ServletRequestReader(servletInputStream, requestContentChannel, jDiscContext.janitor, metricReporter);
    servletInputStream.setReadListener(servletRequestReader);
    return servletRequestReader;
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) ServletInputStream(javax.servlet.ServletInputStream) ContentChannel(com.yahoo.jdisc.handler.ContentChannel) ResourceReference(com.yahoo.jdisc.ResourceReference)

Example 47 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class HttpRequestDispatch method handleRequestFilterResponse.

ContentChannel handleRequestFilterResponse(Response response) {
    try {
        servletRequest.getInputStream().close();
        ContentChannel responseContentChannel = servletResponseController.responseHandler.handleResponse(response);
        servletResponseController.finishedFuture().whenComplete(completeRequestCallback);
        return responseContentChannel;
    } catch (IOException e) {
        throw throwUnchecked(e);
    }
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) IOException(java.io.IOException)

Example 48 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class AccessLoggingRequestHandler method handleRequest.

@Override
public ContentChannel handleRequest(final Request request, final ResponseHandler handler) {
    Preconditions.checkArgument(request instanceof HttpRequest, "Expected HttpRequest, got " + request);
    final HttpRequest httpRequest = (HttpRequest) request;
    httpRequest.context().put(CONTEXT_KEY_ACCESS_LOG_ENTRY, accessLogEntry);
    final ResponseHandler accessLoggingResponseHandler = new AccessLoggingResponseHandler(httpRequest, handler, accessLogEntry);
    final ContentChannel requestContentChannel = delegate.handleRequest(request, accessLoggingResponseHandler);
    return requestContentChannel;
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) ResponseHandler(com.yahoo.jdisc.handler.ResponseHandler) ContentChannel(com.yahoo.jdisc.handler.ContentChannel)

Aggregations

ContentChannel (com.yahoo.jdisc.handler.ContentChannel)48 Test (org.junit.Test)31 Request (com.yahoo.jdisc.Request)10 Response (com.yahoo.jdisc.Response)10 TestDriver (com.yahoo.jdisc.test.TestDriver)10 ByteBuffer (java.nio.ByteBuffer)7 ResponseHandler (com.yahoo.jdisc.handler.ResponseHandler)6 HttpRequest (com.yahoo.jdisc.http.HttpRequest)4 ResourceReference (com.yahoo.jdisc.ResourceReference)3 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)3 Callable (java.util.concurrent.Callable)3 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)2 BindingNotFoundException (com.yahoo.jdisc.handler.BindingNotFoundException)2 RequestDeniedException (com.yahoo.jdisc.handler.RequestDeniedException)2 NonWorkingRequest (com.yahoo.jdisc.test.NonWorkingRequest)2 AbstractRequestHandler (com.yahoo.jdisc.handler.AbstractRequestHandler)1 BufferedContentChannel (com.yahoo.jdisc.handler.BufferedContentChannel)1 ReadableContentChannel (com.yahoo.jdisc.handler.ReadableContentChannel)1 RequestDispatch (com.yahoo.jdisc.handler.RequestDispatch)1 HttpResponse (com.yahoo.jdisc.http.HttpResponse)1