use of com.yahoo.jdisc.handler.ResponseHandler in project vespa by vespa-engine.
the class ServerProviderConformanceTest method testRequestExceptionBeforeResponseWriteWithAsyncHandleResponse.
private <T extends ServerProvider, U, V> void testRequestExceptionBeforeResponseWriteWithAsyncHandleResponse(final Adapter<T, U, V> adapter, final Module... config) throws Throwable {
runTest(adapter, Modules.combine(config), RequestType.WITHOUT_CONTENT, new TestRequestHandler() {
@Override
public ContentChannel handle(final Request request, final ResponseHandler handler) {
final Event exceptionHandledByFramework = new Event();
callInOtherThread(new Callable<Void>() {
@Override
public Void call() throws Exception {
exceptionHandledByFramework.await();
try {
final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK));
exceptionHandledByFramework.await();
writeResponse(out);
closeResponse(out);
} catch (Throwable ignored) {
}
return null;
}
});
throw new ConformanceException(exceptionHandledByFramework);
}
});
}
use of com.yahoo.jdisc.handler.ResponseHandler in project vespa by vespa-engine.
the class ProxyRequestHandlerTestCase method requireThatNullResponseContentIsProxied.
@Test
public void requireThatNullResponseContentIsProxied() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion();
Request request = newRequest(driver, requestHandler);
ResponseHandler responseHandler = new ResponseHandler() {
@Override
public ContentChannel handleResponse(Response response) {
return null;
}
};
request.connect(responseHandler).close(null);
requestHandler.handler.handleResponse(new Response(Response.Status.OK)).close(null);
request.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.handler.ResponseHandler in project vespa by vespa-engine.
the class JDiscFilterInvokerFilter method runRequestFilterWithMatchingBinding.
private HttpServletRequest runRequestFilterWithMatchingBinding(AtomicReference<Boolean> responseReturned, URI uri, HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
RequestFilter requestFilter = jDiscContext.requestFilters.resolve(uri);
if (requestFilter == null)
return request;
ResponseHandler responseHandler = createResponseHandler(responseReturned, request, response);
return filterInvoker.invokeRequestFilterChain(requestFilter, uri, request, responseHandler);
} catch (Exception e) {
throw new RuntimeException("Failed running request filter chain for uri " + uri, e);
}
}
use of com.yahoo.jdisc.handler.ResponseHandler 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));
}
use of com.yahoo.jdisc.handler.ResponseHandler 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;
}
Aggregations