jetty-9 fixed hostHeader handling in ProxyServlet and re-enabled in test webapp

This commit is contained in:
Greg Wilkins 2012-11-19 16:22:27 +11:00
parent f21b74dcb1
commit 82117bc833
2 changed files with 8 additions and 6 deletions

View File

@ -347,6 +347,7 @@ public class ProxyServlet extends HttpServlet
return true;
}
@Override
protected void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
{
final int requestId = getRequestId(request);
@ -380,6 +381,9 @@ public class ProxyServlet extends HttpServlet
// Remove hop-by-hop headers
if (HOP_HEADERS.contains(lowerHeaderName))
continue;
if (_hostHeader!=null && lowerHeaderName.equals("host"))
continue;
for (Enumeration<String> headerValues = request.getHeaders(headerName); headerValues.hasMoreElements();)
{
@ -455,7 +459,7 @@ public class ProxyServlet extends HttpServlet
System.lineSeparator(),
proxyRequest.getHeaders().toString().trim());
}
proxyRequest.send(new TimedResponseListener(getTimeout(), TimeUnit.MILLISECONDS, proxyRequest, new ProxyResponseListener(request, response)));
}

View File

@ -236,19 +236,18 @@
</servlet-mapping>
<!-- TODO
<servlet>
<servlet-name>TransparentProxy</servlet-name>
<servlet-class>org.eclipse.jetty.servlets.ProxyServlet$Transparent</servlet-class>
<async-support>true</async-support>
<init-param>
<param-name>Prefix</param-name><param-value>/javadoc-proxy</param-value>
<param-name>prefix</param-name><param-value>/javadoc-proxy</param-value>
</init-param>
<init-param>
<param-name>ProxyTo</param-name><param-value>http://download.eclipse.org/jetty/stable-8/apidocs</param-value>
<param-name>proxyTo</param-name><param-value>http://download.eclipse.org/jetty/stable-9/apidocs</param-value>
</init-param>
<init-param>
<param-name>HostHeader</param-name><param-value>download.eclipse.org</param-value>
<param-name>hostHeader</param-name><param-value>download.eclipse.org</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
@ -256,7 +255,6 @@
<servlet-name>TransparentProxy</servlet-name>
<url-pattern>/javadoc-proxy/*</url-pattern>
</servlet-mapping>
-->
<servlet>