You are viewing a plain text version of this content. The canonical link for it is here.
Posted to portalapps-dev@portals.apache.org by wo...@apache.org on 2009/09/30 15:57:03 UTC

svn commit: r820270 - in /portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy: HttpReverseProxyConstants.java impl/RewritableHttpReverseProxyServiceImpl.java

Author: woonsan
Date: Wed Sep 30 13:57:03 2009
New Revision: 820270

URL: http://svn.apache.org/viewvc?rev=820270&view=rev
Log:
APA-17: Correcting conent length on posting and ignoring "Range" and "If-Range" request headers.

Modified:
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java?rev=820270&r1=820269&r2=820270&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java Wed Sep 30 13:57:03 2009
@@ -21,6 +21,10 @@
     
     String HTTP_HEADER_LOCATION = "Location";
     
+    String HTTP_HEADER_RANGE = "Range";
+    
+    String HTTP_HEADER_IF_RANGE = "If-Range";
+    
     String PATH_MAPPER = "org.apache.portals.applications.webcontent.proxy.reverseProxyPathMapper";
     
     String SSO_SITE_CREDENTIALS_PROVIDER = "org.apache.portals.applications.webcontent.proxy.reverseProxySSOSiteCredentialsProvider";

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java?rev=820270&r1=820269&r2=820270&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java Wed Sep 30 13:57:03 2009
@@ -33,6 +33,7 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
@@ -222,8 +223,13 @@
         else if ("POST".equals(method))
         {
             httpRequest = new HttpPost(proxyTargetURL);
-            HttpEntity entity = new InputStreamEntity(request.getInputStream(), 4096);
-            ((HttpPost) httpRequest).setEntity(entity);
+            long contentLength = NumberUtils.toLong(request.getHeader(HTTP.CONTENT_LEN));
+            
+            if (contentLength > 0L)
+            {
+                HttpEntity entity = new InputStreamEntity(request.getInputStream(), contentLength);
+                ((HttpPost) httpRequest).setEntity(entity);
+            }
         }
         else
         {
@@ -266,6 +272,12 @@
             if (headerName.equalsIgnoreCase(HTTP.TARGET_HOST))
                 continue;
             
+            if (headerName.equalsIgnoreCase(HttpReverseProxyConstants.HTTP_HEADER_RANGE))
+                continue;
+            
+            if (headerName.equalsIgnoreCase(HttpReverseProxyConstants.HTTP_HEADER_IF_RANGE))
+                continue;
+            
             for (Enumeration enumHeaderValues = request.getHeaders(headerName); enumHeaderValues.hasMoreElements(); )
             {
                 String headerValue = (String) enumHeaderValues.nextElement();