HTTPCLIENT-1073: caching module need not be a stickler about receiving

a 407 (Proxy Authentication Required) response without a Proxy-Authenticate
header and should pass it through to local client.


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1084590 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Moore 2011-03-23 13:54:11 +00:00
parent 8f73a72a1f
commit 08bbd7bc75
2 changed files with 3 additions and 29 deletions

View File

@ -68,8 +68,6 @@ class ResponseProtocolCompliance {
response.setEntity(null);
}
authenticationRequiredDidNotHaveAProxyAuthenticationHeader(request, response);
notAllowedResponseDidNotHaveAnAllowHeader(request, response);
unauthorizedResponseDidNotHaveAWWWAuthenticateHeader(request, response);
@ -150,16 +148,6 @@ class ResponseProtocolCompliance {
}
}
private void authenticationRequiredDidNotHaveAProxyAuthenticationHeader(HttpRequest request,
HttpResponse response) throws ClientProtocolException {
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED)
return;
if (response.getFirstHeader(HeaderConstants.PROXY_AUTHENTICATE) == null)
throw new ClientProtocolException(
"407 Response did not contain a Proxy-Authentication header");
}
private void notAllowedResponseDidNotHaveAnAllowHeader(HttpRequest request,
HttpResponse response) throws ClientProtocolException {
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_METHOD_NOT_ALLOWED)

View File

@ -362,7 +362,7 @@ public class TestProtocolDeviations {
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.8
*/
@Test
public void testCantReturnA407WithoutAProxyAuthenticateHeader() throws Exception {
public void testPassesOnOrigin407WithoutAProxyAuthenticateHeader() throws Exception {
originResponse = new BasicHttpResponse(HTTP_1_1, 407, "Proxy Authentication Required");
org.easymock.EasyMock.expect(
@ -370,23 +370,9 @@ public class TestProtocolDeviations {
org.easymock.EasyMock.isA(HttpRequest.class),
(HttpContext) org.easymock.EasyMock.isNull())).andReturn(originResponse);
replayMocks();
boolean gotException = false;
// this is another case where we are caught in a sticky
// situation, where the origin was not 1.1-compliant.
try {
HttpResponse result = impl.execute(host, request);
Assert.fail("should have gotten ClientProtocolException");
if (result.getStatusLine().getStatusCode() == 407) {
Assert.assertNotNull(result.getFirstHeader("Proxy-Authentication"));
}
} catch (ClientProtocolException possiblyAcceptableBehavior) {
gotException = true;
}
HttpResponse result = impl.execute(host, request);
verifyMocks();
Assert.assertTrue(gotException);
Assert.assertSame(originResponse, result);
}
}