HTTPCLIENT-981: CachingHttpClient returns a 411 respones when executing a POST (HttpPost) request
Contributed by Joe Campbell <joseph.r.campbell at gmail.com> git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@989060 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
68c8b4b1ee
commit
29a4612386
|
@ -63,12 +63,12 @@ class RequestProtocolCompliance {
|
||||||
public List<RequestProtocolError> requestIsFatallyNonCompliant(HttpRequest request) {
|
public List<RequestProtocolError> requestIsFatallyNonCompliant(HttpRequest request) {
|
||||||
List<RequestProtocolError> theErrors = new ArrayList<RequestProtocolError>();
|
List<RequestProtocolError> theErrors = new ArrayList<RequestProtocolError>();
|
||||||
|
|
||||||
RequestProtocolError anError = requestContainsBodyButNoLength(request);
|
//RequestProtocolError anError = requestContainsBodyButNoLength(request);
|
||||||
if (anError != null) {
|
//if (anError != null) {
|
||||||
theErrors.add(anError);
|
// theErrors.add(anError);
|
||||||
}
|
//}
|
||||||
|
|
||||||
anError = requestHasWeakETagAndRange(request);
|
RequestProtocolError anError = requestHasWeakETagAndRange(request);
|
||||||
if (anError != null) {
|
if (anError != null) {
|
||||||
theErrors.add(anError);
|
theErrors.add(anError);
|
||||||
}
|
}
|
||||||
|
@ -330,18 +330,6 @@ class RequestProtocolCompliance {
|
||||||
return null;
|
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) {
|
private RequestProtocolError requestContainsNoCacheDirectiveWithFieldName(HttpRequest request) {
|
||||||
for(Header h : request.getHeaders("Cache-Control")) {
|
for(Header h : request.getHeaders("Cache-Control")) {
|
||||||
for(HeaderElement elt : h.getElements()) {
|
for(HeaderElement elt : h.getElements()) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.easymock.Capture;
|
||||||
import org.easymock.classextension.EasyMock;
|
import org.easymock.classextension.EasyMock;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,8 +147,14 @@ public class TestProtocolDeviations {
|
||||||
* receiving a valid Content-Length."
|
* receiving a valid Content-Length."
|
||||||
*
|
*
|
||||||
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4
|
* 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 {
|
public void testHTTP1_1RequestsWithBodiesOfKnownLengthMustHaveContentLength() throws Exception {
|
||||||
BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
|
BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
|
||||||
HTTP_1_1);
|
HTTP_1_1);
|
||||||
|
@ -180,8 +187,14 @@ public class TestProtocolDeviations {
|
||||||
* needs to happen in order to compute the content length.
|
* needs to happen in order to compute the content length.
|
||||||
*
|
*
|
||||||
* In any event, this test just captures the behavior required.
|
* 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()
|
public void testHTTP1_1RequestsWithUnknownBodyLengthAreRejectedOrHaveContentLengthAdded()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
|
BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
|
||||||
|
|
Loading…
Reference in New Issue