hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r989060 - in /httpcomponents/httpclient/trunk/httpclient-cache/src: main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
Date Wed, 25 Aug 2010 12:28:01 GMT
Author: olegk
Date: Wed Aug 25 12:28:00 2010
New Revision: 989060

URL: http://svn.apache.org/viewvc?rev=989060&view=rev
Log:
HTTPCLIENT-981: CachingHttpClient returns a 411 respones when executing a POST (HttpPost)
request
Contributed by Joe Campbell <joseph.r.campbell at gmail.com>

Modified:
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java?rev=989060&r1=989059&r2=989060&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java
Wed Aug 25 12:28:00 2010
@@ -63,12 +63,12 @@ class RequestProtocolCompliance {
     public List<RequestProtocolError> requestIsFatallyNonCompliant(HttpRequest request)
{
         List<RequestProtocolError> theErrors = new ArrayList<RequestProtocolError>();
 
-        RequestProtocolError anError = requestContainsBodyButNoLength(request);
-        if (anError != null) {
-            theErrors.add(anError);
-        }
+        //RequestProtocolError anError = requestContainsBodyButNoLength(request);
+        //if (anError != null) {
+        //    theErrors.add(anError);
+        //}
 
-        anError = requestHasWeakETagAndRange(request);
+        RequestProtocolError anError = requestHasWeakETagAndRange(request);
         if (anError != null) {
             theErrors.add(anError);
         }
@@ -330,18 +330,6 @@ class RequestProtocolCompliance {
         return null;
     }
 
-    private RequestProtocolError requestContainsBodyButNoLength(HttpRequest request) {
-        if (!(request instanceof HttpEntityEnclosingRequest)) {
-            return null;
-        }
-
-        if (request.getFirstHeader(HTTP.CONTENT_LEN) != null
-                && ((HttpEntityEnclosingRequest) request).getEntity() != null)
-            return null;
-
-        return RequestProtocolError.BODY_BUT_NO_LENGTH_ERROR;
-    }
-
     private RequestProtocolError requestContainsNoCacheDirectiveWithFieldName(HttpRequest
request) {
         for(Header h : request.getHeaders("Cache-Control")) {
             for(HeaderElement elt : h.getElements()) {

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java?rev=989060&r1=989059&r2=989060&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
Wed Aug 25 12:28:00 2010
@@ -49,6 +49,7 @@ import org.easymock.Capture;
 import org.easymock.classextension.EasyMock;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -146,8 +147,14 @@ public class TestProtocolDeviations {
      * receiving a valid Content-Length."
      *
      * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4
+     *
+     * 8/23/2010 JRC - This test has been moved to Ignore.  The caching client
+     * was set to return status code 411 on a missing content-length header when
+     * a request had a body.  It seems that somewhere deeper in the client stack
+     * this header is added automatically for us - so the caching client shouldn't
+     * specifically be worried about this requirement.
      */
-    @Test
+    @Ignore
     public void testHTTP1_1RequestsWithBodiesOfKnownLengthMustHaveContentLength() throws
Exception {
         BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST",
"/",
                 HTTP_1_1);
@@ -180,8 +187,14 @@ public class TestProtocolDeviations {
      * needs to happen in order to compute the content length.
      *
      * In any event, this test just captures the behavior required.
+     *
+     * 8/23/2010 JRC - This test has been moved to Ignore.  The caching client
+     * was set to return status code 411 on a missing content-length header when
+     * a request had a body.  It seems that somewhere deeper in the client stack
+     * this header is added automatically for us - so the caching client shouldn't
+     * specifically be worried about this requirement.
      */
-    @Test
+    @Ignore
     public void testHTTP1_1RequestsWithUnknownBodyLengthAreRejectedOrHaveContentLengthAdded()
             throws Exception {
         BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST",
"/",



Mime
View raw message