felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgil...@apache.org
Subject svn commit: r1214738 - /felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Date Thu, 15 Dec 2011 13:03:24 GMT
Author: kgilmer
Date: Thu Dec 15 13:03:24 2011
New Revision: 1214738

URL: http://svn.apache.org/viewvc?rev=1214738&view=rev
Log:
httplite: fix NPE when handling request paths with successive '/' characters.

Modified:
    felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java

Modified: felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java?rev=1214738&r1=1214737&r2=1214738&view=diff
==============================================================================
--- felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
(original)
+++ felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Thu Dec 15 13:03:24 2011
@@ -197,16 +197,6 @@ public class HttpServletRequestImpl impl
         m_uri = st.nextToken();
         m_version = st.nextToken();
 
-        // If the URI is absolute, break into host and path.
-        m_uriHost = "";
-        int hostIdx = m_uri.indexOf("//");
-        if (hostIdx > 0)
-        {
-            int pathIdx = m_uri.indexOf("/", hostIdx + 2);
-            m_uriHost = m_uri.substring(hostIdx + 2, pathIdx);
-            m_uri = m_uri.substring(pathIdx);
-        }
-
         // If the URI has query string, parse it.
         int qsIdx = m_uri.indexOf("?");
         if (qsIdx > 0)
@@ -214,6 +204,16 @@ public class HttpServletRequestImpl impl
             m_queryString = m_uri.substring(qsIdx + 1);
             m_uri = m_uri.substring(0, qsIdx);
         }
+        
+        //Read the Host parameter if HTTP 1.1
+        if (m_version.equals( "HTTP/1.1"))
+        {
+            m_uriHost = is.readLine();
+            if (m_uriHost == null)
+            {
+                throw new IOException("Unexpected end of file when reading request line.");
+            } 
+        }
     }
 
     /**
@@ -810,7 +810,10 @@ public class HttpServletRequestImpl impl
     public StringBuffer getRequestURL()
     {
         StringBuffer sb = new StringBuffer();
-        sb.append(m_uriHost);
+        if (m_uriHost != null)
+        {
+            sb.append(m_uriHost);
+        }
         sb.append(m_uri);
 
         return sb;



Mime
View raw message