use of org.glassfish.grizzly.http.server.Response in project jersey by jersey.
the class GrizzlyHttpContainer method service.
@Override
public void service(final Request request, final Response response) {
final ResponseWriter responseWriter = new ResponseWriter(response, configSetStatusOverSendError);
try {
logger.debugLog("GrizzlyHttpContainer.service(...) started");
URI baseUri = getBaseUri(request);
URI requestUri = getRequestUri(request);
final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, request.getMethod().getMethodString(), getSecurityContext(request), new GrizzlyRequestPropertiesDelegate(request));
requestContext.setEntityStream(request.getInputStream());
for (final String headerName : request.getHeaderNames()) {
requestContext.headers(headerName, request.getHeaders(headerName));
}
requestContext.setWriter(responseWriter);
requestContext.setRequestScopedInitializer(injectionManager -> {
injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request);
injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response);
});
appHandler.handle(requestContext);
} finally {
logger.debugLog("GrizzlyHttpContainer.service(...) finished");
}
}
use of org.glassfish.grizzly.http.server.Response in project ddf by codice.
the class SecureStubServer method stubsToHandler.
private HttpHandler stubsToHandler() {
return new HttpHandler() {
@Override
public void service(Request request, Response response) throws Exception {
Call call = Call.fromRequest(request);
CallsHelper.logCall(call);
boolean processed = false;
ListIterator<Stub> iterator = stubs.listIterator(stubs.size());
while (iterator.hasPrevious()) {
Stub stub = iterator.previous();
if (!stub.isApplicable(call)) {
continue;
}
stub.apply(response);
processed = true;
break;
}
if (!processed) {
response.setStatus(HttpStatus.NOT_FOUND_404);
LOGGER.debug("Request {} hasn't been covered by any of {} stubs.", request.getRequestURI(), stubs.size());
}
calls.add(call);
}
};
}
Aggregations