You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by kg...@apache.org on 2011/12/15 15:49:05 UTC
svn commit: r1214795 -
/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Author: kgilmer
Date: Thu Dec 15 14:49:04 2011
New Revision: 1214795
URL: http://svn.apache.org/viewvc?rev=1214795&view=rev
Log:
httplite: fix header parsing bug where 2nd line incorrectly assumed to be Host on HTTP/1.1 requests.
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=1214795&r1=1214794&r2=1214795&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 14:49:04 2011
@@ -205,16 +205,6 @@ public class HttpServletRequestImpl impl
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.");
- }
- }
-
// If path contains multiple successive path separators (a//b/c a/b////c, etc.), strip them.
if (m_uri.indexOf( "//" ) > -1)
{
@@ -271,7 +261,7 @@ public class HttpServletRequestImpl impl
* If any I/O error occurs.
**/
public void parseHeader(final ConcreteServletInputStream is) throws IOException
- {
+ {
for (String s = is.readLine(); (s != null) && (s.length() != 0); s = is.readLine())
{
int idx = s.indexOf(":");
@@ -309,6 +299,11 @@ public class HttpServletRequestImpl impl
}
}
}
+
+ if (m_headers.containsKey( "Host" ))
+ {
+ m_uriHost = m_headers.get( "Host" ).toString();
+ }
}
/**
@@ -543,6 +538,19 @@ public class HttpServletRequestImpl impl
*/
public Map getParameterMap()
{
+ if (m_parameters == null)
+ {
+ try
+ {
+ m_parameters = parseParameters();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ m_logger.log(Logger.LOG_ERROR, "Failed to parse request parameters.", e);
+ return null;
+ }
+ }
+
return m_parameters;
}
@@ -553,6 +561,19 @@ public class HttpServletRequestImpl impl
*/
public Enumeration getParameterNames()
{
+ if (m_parameters == null)
+ {
+ try
+ {
+ m_parameters = parseParameters();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ m_logger.log(Logger.LOG_ERROR, "Failed to parse request parameters.", e);
+ return null;
+ }
+ }
+
return Collections.enumeration(m_parameters.keySet());
}
@@ -563,6 +584,19 @@ public class HttpServletRequestImpl impl
*/
public String[] getParameterValues(String arg0)
{
+ if (m_parameters == null)
+ {
+ try
+ {
+ m_parameters = parseParameters();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ m_logger.log(Logger.LOG_ERROR, "Failed to parse request parameters.", e);
+ return null;
+ }
+ }
+
return (String[]) m_parameters.values().toArray(new String[m_parameters.size()]);
}
@@ -947,12 +981,12 @@ public class HttpServletRequestImpl impl
parseParameterString(queryString, params);
}
- if (m_requestBody != null)
+ if (m_requestBody != null && m_requestBody.length > 0)
{
parseParameterString(new String(m_requestBody), params);
}
- return params;
+ return Collections.unmodifiableMap( params );
}
/**