hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1084590 - in /httpcomponents/httpclient/trunk/httpclient-cache/src: main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
Date Wed, 23 Mar 2011 13:54:12 GMT
Author: jonm
Date: Wed Mar 23 13:54:11 2011
New Revision: 1084590

URL: http://svn.apache.org/viewvc?rev=1084590&view=rev
Log:
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.

Modified:
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.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/ResponseProtocolCompliance.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java?rev=1084590&r1=1084589&r2=1084590&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java
Wed Mar 23 13:54:11 2011
@@ -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)

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=1084590&r1=1084589&r2=1084590&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 Mar 23 13:54:11 2011
@@ -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);
     }
 
 }
\ No newline at end of file



Mime
View raw message