YARN-6615. AmIpFilter drops query parameters on redirect. Contributed by Wilfred Spiegelenburg
This commit is contained in:
parent
a62be38a5e
commit
8bf1949c0e
|
@ -150,6 +150,12 @@ public class AmIpFilter implements Filter {
|
||||||
insertPoint += PROXY_PATH.length();
|
insertPoint += PROXY_PATH.length();
|
||||||
redirect.insert(insertPoint, "/redirect");
|
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());
|
ProxyUtils.sendRedirect(httpReq, httpResp, redirect.toString());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -176,6 +176,14 @@ public class TestAmFilter {
|
||||||
redirect = response.getHeader(ProxyUtils.LOCATION);
|
redirect = response.getHeader(ProxyUtils.LOCATION);
|
||||||
assertEquals("http://bogus/proxy/redirect/application_00_0", redirect);
|
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
|
// "127.0.0.1" contains in host list. Without cookie
|
||||||
Mockito.when(request.getRemoteAddr()).thenReturn("127.0.0.1");
|
Mockito.when(request.getRemoteAddr()).thenReturn("127.0.0.1");
|
||||||
testFilter.doFilter(request, response, chain);
|
testFilter.doFilter(request, response, chain);
|
||||||
|
|
Loading…
Reference in New Issue