Search in sources :

Example 46 with HttpRequest

use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.

the class FilterTestCase method requireThatRequestFilterChainIsRun.

@Test
public void requireThatRequestFilterChainIsRun() throws Exception {
    final RequestFilter requestFilter1 = mock(RequestFilter.class);
    final RequestFilter requestFilter2 = mock(RequestFilter.class);
    final RequestFilter requestFilterChain = RequestFilterChain.newInstance(requestFilter1, requestFilter2);
    final HttpRequest request = null;
    final ResponseHandler responseHandler = null;
    requestFilterChain.filter(request, responseHandler);
    verify(requestFilter1).filter(any(HttpRequest.class), any(ResponseHandler.class));
    verify(requestFilter2).filter(any(HttpRequest.class), any(ResponseHandler.class));
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) ResponseHandler(com.yahoo.jdisc.handler.ResponseHandler) RequestFilter(com.yahoo.jdisc.http.filter.RequestFilter) Test(org.testng.annotations.Test)

Example 47 with HttpRequest

use of com.yahoo.jdisc.http.HttpRequest 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 48 with HttpRequest

use of com.yahoo.jdisc.http.HttpRequest 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

HttpRequest (com.yahoo.jdisc.http.HttpRequest)48 Test (org.testng.annotations.Test)36 URI (java.net.URI)27 ResponseHandler (com.yahoo.jdisc.handler.ResponseHandler)7 HttpResponse (com.yahoo.jdisc.http.HttpResponse)7 RequestFilter (com.yahoo.jdisc.http.filter.RequestFilter)5 VipStatusConfig (com.yahoo.container.core.VipStatusConfig)4 BufferedContentChannel (com.yahoo.jdisc.handler.BufferedContentChannel)4 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)4 Cookie (com.yahoo.jdisc.http.Cookie)4 InetSocketAddress (java.net.InetSocketAddress)4 ByteBuffer (java.nio.ByteBuffer)4 Test (org.junit.Test)4 Response (com.yahoo.jdisc.Response)2 TestDriver (com.yahoo.jdisc.test.TestDriver)2 HeaderFields (com.yahoo.jdisc.HeaderFields)1 ResourceReference (com.yahoo.jdisc.ResourceReference)1 AbstractRequestHandler (com.yahoo.jdisc.handler.AbstractRequestHandler)1 BindingNotFoundException (com.yahoo.jdisc.handler.BindingNotFoundException)1 FastContentWriter (com.yahoo.jdisc.handler.FastContentWriter)1