diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/amfilter/AmIpFilter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/amfilter/AmIpFilter.java index fe6fc329b5..6579191024 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/amfilter/AmIpFilter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/amfilter/AmIpFilter.java @@ -150,6 +150,12 @@ public void doFilter(ServletRequest req, ServletResponse resp, insertPoint += PROXY_PATH.length(); redirect.insert(insertPoint, "/redirect"); } + // add the query parameters on the redirect if there were any + String queryString = httpReq.getQueryString(); + if (queryString != null && !queryString.isEmpty()) { + redirect.append("?"); + redirect.append(queryString); + } ProxyUtils.sendRedirect(httpReq, httpResp, redirect.toString()); } else { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/amfilter/TestAmFilter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/amfilter/TestAmFilter.java index 9dc0ce0f10..b788f5d80f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/amfilter/TestAmFilter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/amfilter/TestAmFilter.java @@ -176,6 +176,14 @@ public void doFilter(ServletRequest servletRequest, redirect = response.getHeader(ProxyUtils.LOCATION); assertEquals("http://bogus/proxy/redirect/application_00_0", redirect); + // check for query parameters + Mockito.when(request.getRequestURI()).thenReturn("/proxy/application_00_0"); + Mockito.when(request.getQueryString()).thenReturn("id=0"); + testFilter.doFilter(request, response, chain); + assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, response.status); + redirect = response.getHeader(ProxyUtils.LOCATION); + assertEquals("http://bogus/proxy/redirect/application_00_0?id=0", redirect); + // "127.0.0.1" contains in host list. Without cookie Mockito.when(request.getRemoteAddr()).thenReturn("127.0.0.1"); testFilter.doFilter(request, response, chain);