HTTPCLIENT-1073: caching module should not reject an origin 405
(Method Not Allowed) response just because it is missing an Allow header, even though this is required by RFC2616; this has no effect on the caching module itself. git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1084610 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e9864b06ff
commit
32221a1a48
|
@ -73,8 +73,6 @@ class ResponseProtocolCompliance {
|
||||||
response.setEntity(null);
|
response.setEntity(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
notAllowedResponseDidNotHaveAnAllowHeader(request, response);
|
|
||||||
|
|
||||||
unauthorizedResponseDidNotHaveAWWWAuthenticateHeader(request, response);
|
unauthorizedResponseDidNotHaveAWWWAuthenticateHeader(request, response);
|
||||||
|
|
||||||
requestDidNotExpect100ContinueButResponseIsOne(request, response);
|
requestDidNotExpect100ContinueButResponseIsOne(request, response);
|
||||||
|
@ -153,15 +151,6 @@ class ResponseProtocolCompliance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notAllowedResponseDidNotHaveAnAllowHeader(HttpRequest request,
|
|
||||||
HttpResponse response) throws ClientProtocolException {
|
|
||||||
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_METHOD_NOT_ALLOWED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (response.getFirstHeader(HeaderConstants.ALLOW) == null)
|
|
||||||
throw new ClientProtocolException("405 Response did not contain an Allow header.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void unauthorizedResponseDidNotHaveAWWWAuthenticateHeader(HttpRequest request,
|
private void unauthorizedResponseDidNotHaveAWWWAuthenticateHeader(HttpRequest request,
|
||||||
HttpResponse response) throws ClientProtocolException {
|
HttpResponse response) throws ClientProtocolException {
|
||||||
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_UNAUTHORIZED)
|
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_UNAUTHORIZED)
|
||||||
|
|
|
@ -334,8 +334,8 @@ public class TestProtocolDeviations {
|
||||||
*
|
*
|
||||||
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2
|
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2
|
||||||
*/
|
*/
|
||||||
@Test(expected = ClientProtocolException.class)
|
@Test
|
||||||
public void testCantReturnAnOrigin405WithoutAllowHeader() throws Exception {
|
public void testPassesOnOrigin405WithoutAllowHeader() throws Exception {
|
||||||
originResponse = new BasicHttpResponse(HTTP_1_1, 405, "Method Not Allowed");
|
originResponse = new BasicHttpResponse(HTTP_1_1, 405, "Method Not Allowed");
|
||||||
|
|
||||||
org.easymock.EasyMock.expect(
|
org.easymock.EasyMock.expect(
|
||||||
|
@ -343,15 +343,9 @@ public class TestProtocolDeviations {
|
||||||
org.easymock.EasyMock.isA(HttpRequest.class),
|
org.easymock.EasyMock.isA(HttpRequest.class),
|
||||||
(HttpContext) org.easymock.EasyMock.isNull())).andReturn(originResponse);
|
(HttpContext) org.easymock.EasyMock.isNull())).andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
|
HttpResponse result = impl.execute(host, request);
|
||||||
// this is another case where we are caught in a sticky
|
|
||||||
// situation, where the origin was not 1.1-compliant.
|
|
||||||
try {
|
|
||||||
impl.execute(host, request);
|
|
||||||
} catch (ClientProtocolException possiblyAcceptableBehavior) {
|
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
throw possiblyAcceptableBehavior;
|
Assert.assertSame(originResponse, result);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue