extracted overridable method for condition

Project: http://git-wip-us.apache.org/repos/asf/struts-extras/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-extras/commit/785a77fc
Tree: http://git-wip-us.apache.org/repos/asf/struts-extras/tree/785a77fc
Diff: http://git-wip-us.apache.org/repos/asf/struts-extras/diff/785a77fc

Branch: refs/heads/master
Commit: 785a77fcfc85c4e8643b1379c3304563bd2705a5
Parents: b4b8c2d
Author: Stefaan Dutry <stefaan.du...@gmail.com>
Authored: Tue Mar 28 08:45:58 2017 +0200
Committer: Stefaan Dutry <stefaan.du...@gmail.com>
Committed: Tue Mar 28 08:45:58 2017 +0200

----------------------------------------------------------------------
 .../struts2/result/HttpsOffloadAwareServletRedirectResult.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-extras/blob/785a77fc/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
----------------------------------------------------------------------
diff --git 
a/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
 
b/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
index a211afb..5c70339 100644
--- 
a/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
+++ 
b/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
@@ -136,7 +136,7 @@ public class HttpsOffloadAwareServletRedirectResult extends 
ServletRedirectResul
     }
 
     protected String fixSchemeIfNeeded(String location, HttpServletRequest 
request) {
-        if ("https".equals(request.getHeader("X-Forwarded-Proto"))) {
+        if (shouldFixScheme(request)) {
             LOG.debug("https offloading happened, fixing redirectlocation");
             StringBuilder fixedLocation = new StringBuilder();
             fixedLocation.append("https");
@@ -154,4 +154,8 @@ public class HttpsOffloadAwareServletRedirectResult extends 
ServletRedirectResul
         }
     }
 
+    protected boolean shouldFixScheme(HttpServletRequest request) {
+        return "https".equals(request.getHeader("X-Forwarded-Proto"));
+    }
+
 }

Reply via email to