knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject [5/6] knox git commit: Revert "KNOX-754 scope change to just the Location header"
Date Sat, 17 Jun 2017 14:18:51 GMT
Revert "KNOX-754 scope change to just the Location header"

This reverts commit 2d77f09f86134f4b665a7bbae2d7c04461e114fc.


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

Branch: refs/heads/master
Commit: 537690745cb4fc88d5083367d37f2a71de03e2e9
Parents: 5bbc4f9
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Tue Jun 13 17:44:01 2017 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Tue Jun 13 17:44:01 2017 -0400

----------------------------------------------------------------------
 .../filter/rewrite/impl/UrlRewriteResponse.java  | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/53769074/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
index 35ab677..d3b00b0 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
@@ -111,16 +111,12 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements
Params
     return IGNORE_HEADER_NAMES.contains( name );
   }
 
-  private String rewriteValue(String value, String rule, boolean encode ) {
+  private String rewriteValue( String value, String rule ) {
     try {
       Template input = Parser.parseLiteral( value );
       Template output = rewriter.rewrite( this, input, UrlRewriter.Direction.OUT, rule );
       if( output != null ) {
-        if (encode) {
-          value = output.toEncodedString();
-        } else {
-          value = output.getPattern();
-        }
+        value = output.toEncodedString();
       }
     } catch( URISyntaxException e ) {
       LOG.failedToParseValueForUrlRewrite( value );
@@ -132,7 +128,7 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements
Params
   @Override
   public void setHeader( String name, String value ) {
     if( !ignoreHeader( name) ) {
-      value = rewriteValue( value, pickFirstRuleWithEqualsIgnoreCasePathMatch( headersFilterConfig,
name ), needsEncoding(name) );
+      value = rewriteValue( value, pickFirstRuleWithEqualsIgnoreCasePathMatch( headersFilterConfig,
name ) );
       super.setHeader( name, value );
     }
   }
@@ -142,18 +138,11 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements
Params
   public void addHeader( String name, String value ) {
     if( !ignoreHeader( name ) ) {
       String rule = pickFirstRuleWithEqualsIgnoreCasePathMatch( headersFilterConfig, name
);
-      value = rewriteValue( value, rule, needsEncoding(name) );
+      value = rewriteValue( value, rule );
       super.addHeader( name, value );
     }
   }
 
-  private boolean needsEncoding( String name ) {
-    if ( name.equalsIgnoreCase("Location") ) {
-      return true;
-    }
-    return false;
-  }
-
   @Override
   public OutputStream getRawOutputStream() throws IOException {
     return response.getOutputStream();


Mime
View raw message