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:37:12 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.6 c73c89401 -> 1b206d10f


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/1b206d10
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1b206d10
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1b206d10

Branch: refs/heads/branch-2.6
Commit: 1b206d10fb8411164e91288692f2b2a2805178ac
Parents: c73c894
Author: Jason Lowe <jlowe@yahoo-inc.com>
Authored: Wed May 24 11:36:02 2017 -0500
Committer: Jason Lowe <jlowe@yahoo-inc.com>
Committed: Wed May 24 11:36:02 2017 -0500

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                     | 15 +++++++++++++++
 .../yarn/server/webproxy/amfilter/AmIpFilter.java   | 16 +++++++++++++---
 .../yarn/server/webproxy/amfilter/TestAmFilter.java | 13 +++++++++++++
 3 files changed, 41 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/1b206d10/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index f7cf9c4..90d94c4 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -1,5 +1,20 @@
 Hadoop YARN Change Log
 
+Release 2.6.6 - UNRELEASED
+
+  INCOMPATIBLE CHANGES
+
+  NEW FEATURES
+
+  IMPROVEMENTS
+
+  OPTIMIZATIONS
+
+  BUG FIXES
+
+    YARN-6615. AmIpFilter drops query parameters on redirect. (Wilfred
+    Spiegelenburg via jlowe)
+
 Release 2.6.5 - 2016-10-08
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/1b206d10/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 49eabaa..4b46327 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
@@ -25,6 +25,7 @@ import java.net.URL;
 import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -45,6 +46,8 @@ import org.apache.hadoop.yarn.conf.HAUtil;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.webproxy.WebAppProxyServlet;
 import org.apache.hadoop.yarn.util.RMHAUtils;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
 
 @Public
 public class AmIpFilter implements Filter {
@@ -136,9 +139,16 @@ public class AmIpFilter implements Filter {
       LOG.debug("Remote address for request is: " + httpReq.getRemoteAddr());
     }
     if(!getProxyAddresses().contains(httpReq.getRemoteAddr())) {
-      String redirectUrl = findRedirectUrl();
-      redirectUrl = httpResp.encodeRedirectURL(redirectUrl +
-          httpReq.getRequestURI());
+      StringBuilder target = new StringBuilder().append(findRedirectUrl());
+      target.append(httpReq.getRequestURI());
+      String queryParams = httpReq.getQueryString();
+      if (queryParams != null && !queryParams.isEmpty()) {
+        target.append("?");
+        List<NameValuePair> queryPairs =
+            URLEncodedUtils.parse(queryParams, null);
+        target.append(URLEncodedUtils.format(queryPairs, "UTF-8"));
+      }
+      String redirectUrl = httpResp.encodeRedirectURL(target.toString());
       httpResp.sendRedirect(redirectUrl);
       return;
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/1b206d10/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 001dcf9..e5061ee 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
@@ -161,6 +161,19 @@ public class TestAmFilter {
     testFilter.doFilter(request, response, chain);
     // address "redirect" is not in host list
     assertEquals("http://bogus/redirect", response.getRedirect());
+    // 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("http://bogus/proxy/application_00_0?id=0",
+        response.getRedirect());
+    // check for query parameters: encoding
+    Mockito.when(request.getRequestURI()).thenReturn("/proxy/application_00_0");
+    Mockito.when(request.getQueryString()).thenReturn("id=0&text=' #'");
+    testFilter.doFilter(request, response, chain);
+    assertEquals("http://bogus/proxy/application_00_0?id=0&text=%27+%23%27",
+        response.getRedirect());
+
     // "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