EnvironmentContext envctx = new EnvironmentContext();
HttpServletRequest httpRequest =
new MockHttpServletRequest(in, in != null ? in.available() : 0, method, new InputHeadersMap(headers));
envctx.put(HttpServletRequest.class, httpRequest);
EnvironmentContext.setCurrent(envctx);
ContainerRequest request =
new ContainerRequest(method, new URI(requestURI), new URI(baseURI), in, new InputHeadersMap(headers));
ContainerResponse response = new ContainerResponse(writer);
requestHandler.handleRequest(request, response);
return response;
}