| Summary: | jetty.servlets.ProxyServlet.service() doesn't update ServletResponse's contentType | ||
|---|---|---|---|
| Product: | [RT] Jetty | Reporter: | M.S. <bugs198011> |
| Component: | server | Assignee: | Thomas Becker <tbecker> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | gregw, jetty-inbox |
| Version: | 7.1.5 | ||
| Target Milestone: | 7.1.x | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
M.S.
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. |