hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1100301 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src: main/java/org/apache/http/impl/nio/client/ main/java/org/apache/http/impl/nio/conn/ test/java/org/apache/http/impl/nio/client/
Date Fri, 06 May 2011 17:51:09 GMT
Author: olegk
Date: Fri May  6 17:51:08 2011
New Revision: 1100301

URL: http://svn.apache.org/viewvc?rev=1100301&view=rev
Log:
Fixed handling of non-repeatable entity enclosing requests

Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1100301&r1=1100300&r2=1100301&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
Fri May  6 17:51:08 2011
@@ -54,6 +54,7 @@ import org.apache.http.auth.Credentials;
 import org.apache.http.auth.MalformedChallengeException;
 import org.apache.http.client.AuthenticationHandler;
 import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.NonRepeatableRequestException;
 import org.apache.http.client.RedirectException;
 import org.apache.http.client.RedirectStrategy;
 import org.apache.http.client.methods.HttpUriRequest;
@@ -123,6 +124,7 @@ class DefaultAsyncRequestDirector<T> imp
     private ManagedClientConnection managedConn;
     private int redirectCount;
     private ByteBuffer tmpbuf;
+    private boolean requestContentProduced;
 
     public DefaultAsyncRequestDirector(
             final Log log,
@@ -168,6 +170,7 @@ class DefaultAsyncRequestDirector<T> imp
             wrapper.setParams(this.params);
             HttpRoute route = determineRoute(target, wrapper, this.localContext);
             this.mainRequest = new RoutedRequest(wrapper, route);
+            this.requestContentProduced = false;
             requestConnection();
         } catch (Exception ex) {
             failed(ex);
@@ -238,11 +241,19 @@ class DefaultAsyncRequestDirector<T> imp
         if (this.log.isDebugEnabled()) {
             this.log.debug("Request submitted: " + this.currentRequest.getRequestLine());
         }
+        this.currentRequest.incrementExecCount();
+        if (this.currentRequest.getExecCount() > 1
+                && !this.requestProducer.isRepeatable()
+                && this.requestContentProduced) {
+            throw new NonRepeatableRequestException("Cannot retry request " +
+                "with a non-repeatable request entity.");
+        }
         return this.currentRequest;
     }
 
     public synchronized void produceContent(
             final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+        this.requestContentProduced = true;
         this.requestProducer.produceContent(encoder, ioctrl);
         if (encoder.isCompleted()) {
             this.requestProducer.resetRequest();

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java?rev=1100301&r1=1100300&r2=1100301&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/DefaultHttpAsyncRoutePlanner.java
Fri May  6 17:51:08 2011
@@ -35,7 +35,6 @@ import org.apache.http.HttpRequest;
 import org.apache.http.nio.conn.scheme.LayeringStrategy;
 import org.apache.http.nio.conn.scheme.Scheme;
 import org.apache.http.nio.conn.scheme.SchemeRegistry;
-import org.apache.http.params.HttpProtocolParamBean;
 import org.apache.http.protocol.HttpContext;
 
 import org.apache.http.conn.routing.HttpRoute;

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java?rev=1100301&r1=1100300&r2=1100301&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/client/TestClientAuthentication.java
Fri May  6 17:51:08 2011
@@ -63,7 +63,6 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestClientAuthentication extends AsyncHttpTestBase {
@@ -271,7 +270,7 @@ public class TestClientAuthentication ex
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
     }
 
-    @Test(expected=ExecutionException.class) @Ignore
+    @Test(expected=ExecutionException.class)
     public void testBasicAuthenticationFailureWithNonRepeatableEntityExpectContinueOff()
throws Exception {
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));



Mime
View raw message