From aa75bcf078d36ca7d03777b749ccbc2e42ef0175 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 28 Jul 2015 16:18:41 +0200 Subject: [PATCH 1/2] Updated ALPN versions for JDK 8u51. --- .../config/modules/protonego-impl/alpn-1.8.0_51.mod | 8 ++++++++ .../modules/protonego-impl/alpn-1.8.0_51.mod | 8 ++++++++ pom.xml | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_51.mod create mode 100644 jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_51.mod diff --git a/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_51.mod b/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_51.mod new file mode 100644 index 00000000000..ddc18d7d7ca --- /dev/null +++ b/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_51.mod @@ -0,0 +1,8 @@ +[name] +protonego-boot + +[files] +http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.4.v20150727/alpn-boot-8.1.4.v20150727.jar|lib/alpn/alpn-boot-8.1.4.v20150727.jar + +[exec] +-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.4.v20150727.jar diff --git a/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_51.mod b/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_51.mod new file mode 100644 index 00000000000..ddc18d7d7ca --- /dev/null +++ b/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_51.mod @@ -0,0 +1,8 @@ +[name] +protonego-boot + +[files] +http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.4.v20150727/alpn-boot-8.1.4.v20150727.jar|lib/alpn/alpn-boot-8.1.4.v20150727.jar + +[exec] +-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.4.v20150727.jar diff --git a/pom.xml b/pom.xml index f509f774c68..a5985ec6333 100644 --- a/pom.xml +++ b/pom.xml @@ -1108,5 +1108,17 @@ 8.1.3.v20150130 + + 8u51 + + + java.version + 1.8.0_51 + + + + 8.1.4.v20150727 + + From 837d1a74bb7d694220644a2539c4440ce55462cf Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 28 Jul 2015 16:39:49 +0200 Subject: [PATCH 2/2] 473624 - ProxyServlet.Transparent / TransparentDelegate add trailing slash before query when using prefix. --- .../jetty/proxy/AbstractProxyServlet.java | 16 ++++- .../eclipse/jetty/proxy/ProxyServletTest.java | 69 ++++++++++++++++++- 2 files changed, 81 insertions(+), 4 deletions(-) diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java index 862d58236bf..49f4d546c56 100644 --- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java +++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java @@ -704,12 +704,22 @@ public abstract class AbstractProxyServlet extends HttpServlet if (_proxyTo.endsWith("/")) uri.setLength(uri.length() - 1); String rest = path.substring(_prefix.length()); - if (!rest.startsWith("/")) - uri.append("/"); - uri.append(rest); + if (!rest.isEmpty()) + { + if (!rest.startsWith("/")) + uri.append("/"); + uri.append(rest); + } + String query = request.getQueryString(); if (query != null) + { + // Is there at least one path segment ? + String separator = "://"; + if (uri.indexOf("/", uri.indexOf(separator) + separator.length()) < 0) + uri.append("/"); uri.append("?").append(query); + } URI rewrittenURI = URI.create(uri.toString()).normalize(); if (!proxyServlet.validateDestination(rewrittenURI.getHost(), rewrittenURI.getPort())) diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java index a4be2815b53..f4f36d68681 100644 --- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java +++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java @@ -44,6 +44,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.zip.GZIPOutputStream; + import javax.servlet.AsyncContext; import javax.servlet.AsyncEvent; import javax.servlet.AsyncListener; @@ -650,9 +651,75 @@ public class ProxyServletTest @Test public void testTransparentProxyWithQuery() throws Exception { - final String target = "/test"; + testTransparentProxyWithQuery("/foo", "/proxy", "/test"); + } + + @Test + public void testTransparentProxyEmptyContextWithQuery() throws Exception + { + testTransparentProxyWithQuery("", "/proxy", "/test"); + } + + @Test + public void testTransparentProxyEmptyTargetWithQuery() throws Exception + { + testTransparentProxyWithQuery("/bar", "/proxy", ""); + } + + @Test + public void testTransparentProxyEmptyContextEmptyTargetWithQuery() throws Exception + { + testTransparentProxyWithQuery("", "/proxy", ""); + } + + private void testTransparentProxyWithQuery(final String proxyToContext, String prefix, final String target) throws Exception + { final String query = "a=1&b=2"; startServer(new HttpServlet() + { + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + if (req.getHeader("Via") != null) + resp.addHeader(PROXIED_HEADER, "true"); + + String expectedURI = proxyToContext + target; + if (expectedURI.isEmpty()) + expectedURI = "/"; + if (expectedURI.equals(req.getRequestURI())) + { + if (query.equals(req.getQueryString())) + { + resp.setStatus(200); + return; + } + } + resp.setStatus(404); + } + }); + String proxyTo = "http://localhost:" + serverConnector.getLocalPort() + proxyToContext; + proxyServlet = new ProxyServlet.Transparent(); + Map params = new HashMap<>(); + params.put("proxyTo", proxyTo); + params.put("prefix", prefix); + startProxy(params); + startClient(); + + // Make the request to the proxy, it should transparently forward to the server + ContentResponse response = client.newRequest("localhost", proxyConnector.getLocalPort()) + .path(prefix + target + "?" + query) + .timeout(5, TimeUnit.SECONDS) + .send(); + Assert.assertEquals(200, response.getStatus()); + Assert.assertTrue(response.getHeaders().containsKey(PROXIED_HEADER)); + } + + @Test + public void testTransparentProxyWithQueryWithSpaces() throws Exception + { + final String target = "/test"; + final String query = "a=1&b=2&c=1234%205678&d=hello+world"; + startServer(new HttpServlet() { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException