FELIX-4196 Check existing request URL prefix before replacing it with "https"

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1515389 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java b/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java
index 62c955d..e3cf616 100644
--- a/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java
+++ b/http/sslfilter/src/main/java/org/apache/felix/http/sslfilter/internal/SslFilterRequest.java
@@ -21,21 +21,25 @@
 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 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);