Community
Participate
Working Groups
In my Jetty-7 (version 7.1.6) based application, I wrote a class(MyProxyServlet) that extends org.eclipse.jetty.servlets.ProxyServlet. MyProxyServlet's service(ServletRequest req, ServletResponse res) method calls super.service(req, res). Afterward, I call res.getContentType() and the result is always NULL.
The response will contain the ContentType header, but not inside your service method. The reason is the async behaviour of org.eclipse.jetty.servlets.ProxyServlet. I will make up my mind to see how we can help.
Hi M.S., as said your request is being processed asynchronously by ProxyServlet.service(). That's why the response object is unchanged when you call it right after your super.service(req,res) call. The easiest way is to add a Listener to the Continuation like this: private class ProxyServletChild extends ProxyServlet { @Override public void service(final ServletRequest req, ServletResponse res) throws ServletException, IOException { ContinuationListener continuationListener = new ContinuationListener() { public void onComplete(Continuation continuation) { System.out.println("onComplete: " + req.getContentType()); } public void onTimeout(Continuation continuation) { } }; Continuation continuation = ContinuationSupport.getContinuation(req); continuation.addContinuationListener(continuationListener); super.service(req,res); System.out.println("Null here, because the proxied request hasn't been processed yet. ContentType: " + res.getContentType()); } } Hope this helps you. If it does, please close the issue. If not, let me know. Cheers, Thomas
Note you could also add the listener in a filter before the proxy servlet.