felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1515389 - /felix/trunk/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java
Date Mon, 19 Aug 2013 12:42:35 GMT
Author: fmeschbe
Date: Mon Aug 19 12:42:35 2013
New Revision: 1515389

URL: http://svn.apache.org/r1515389
Log:
FELIX-4196 Check existing request URL prefix before replacing it with "https"

Modified:
    felix/trunk/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java

Modified: felix/trunk/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java?rev=1515389&r1=1515388&r2=1515389&view=diff
==============================================================================
--- felix/trunk/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java
(original)
+++ felix/trunk/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java
Mon Aug 19 12:42:35 2013
@@ -21,21 +21,25 @@ package org.apache.felix.http.sslfilter.
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 
-public class SslFilterRequest extends HttpServletRequestWrapper
+class SslFilterRequest extends HttpServletRequestWrapper
 {
 
+    // The HTTPS scheme name
+    private static final String HTTPS_SCHEME = "https";
+
+    // The HTTP scheme prefix in an URL
+    private static final String HTTP_SCHEME_PREFIX = "http://";
+
     private String requestURL;
 
-    public SslFilterRequest(HttpServletRequest request)
+    SslFilterRequest(HttpServletRequest request)
     {
         super(request);
-
-        // TODO: check request headers for SSL attribute information
     }
 
     public String getScheme()
     {
-        return "https";
+        return HTTPS_SCHEME;
     }
 
     public boolean isSecure()
@@ -45,11 +49,17 @@ public class SslFilterRequest extends Ht
 
     public StringBuffer getRequestURL()
     {
-        if (this.requestURL == null) {
-            // insert an 's' after the http scheme
+        if (this.requestURL == null)
+        {
             StringBuffer tmp = super.getRequestURL();
-            tmp.insert(4, 's');
-            this.requestURL = tmp.toString();
+            if (tmp.indexOf(HTTP_SCHEME_PREFIX) == 0)
+            {
+                this.requestURL = HTTPS_SCHEME.concat(tmp.substring(4));
+            }
+            else
+            {
+                this.requestURL = tmp.toString();
+            }
         }
 
         return new StringBuffer(this.requestURL);



Mime
View raw message