hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject hadoop git commit: YARN-6615. AmIpFilter drops query parameters on redirect. Contributed by Wilfred Spiegelenburg
Date Wed, 24 May 2017 16:29:46 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 462c6fb5b -> 7ef01c7c4


YARN-6615. AmIpFilter drops query parameters on redirect. Contributed by Wilfred Spiegelenburg


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7ef01c7c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7ef01c7c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7ef01c7c

Branch: refs/heads/branch-2.8
Commit: 7ef01c7c49e38529557322dbb6fce3e310cb7826
Parents: 462c6fb
Author: Jason Lowe <jlowe@yahoo-inc.com>
Authored: Wed May 24 11:27:21 2017 -0500
Committer: Jason Lowe <jlowe@yahoo-inc.com>
Committed: Wed May 24 11:27:21 2017 -0500

----------------------------------------------------------------------
 .../yarn/server/webproxy/amfilter/AmIpFilter.java      | 13 ++++++++++---
 .../yarn/server/webproxy/amfilter/TestAmFilter.java    | 11 ++++++++++-
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7ef01c7c/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
----------------------------------------------------------------------
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 e7617f0..705a7d0 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
@@ -135,9 +135,16 @@ public class AmIpFilter implements Filter {
       LOG.debug("Remote address for request is: {}", httpReq.getRemoteAddr());
     }
     if (!getProxyAddresses().contains(httpReq.getRemoteAddr())) {
-      String redirectUrl = findRedirectUrl();
-      String target = redirectUrl + httpReq.getRequestURI();
-      ProxyUtils.sendRedirect(httpReq,  httpResp,  target);
+      StringBuilder target = new StringBuilder().append(findRedirectUrl());
+      target.append(httpReq.getRequestURI());
+      // add the query parameters on the redirect if there were any
+      String queryString = httpReq.getQueryString();
+      if (queryString != null && !queryString.isEmpty()) {
+        target.append("?");
+        target.append(queryString);
+      }
+
+      ProxyUtils.sendRedirect(httpReq,  httpResp,  target.toString());
       return;
     }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7ef01c7c/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
----------------------------------------------------------------------
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 6f64777..67bbc64 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
@@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.webproxy.amfilter;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.HttpURLConnection;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -163,9 +164,17 @@ public class TestAmFilter {
     Mockito.when(request.getRequestURI()).thenReturn("/redirect");
     testFilter.doFilter(request, response, chain);
     // address "redirect" is not in host list
-    assertEquals(302, response.status);
+    assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, response.status);
     String redirect = response.getHeader(ProxyUtils.LOCATION);
     assertEquals("http://bogus/redirect", 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/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);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message