hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1228873 - in /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol: HttpAsyncExchange.java HttpAsyncRequestExecutor.java HttpAsyncService.java
Date Sun, 08 Jan 2012 15:50:13 GMT
Author: olegk
Date: Sun Jan  8 15:50:13 2012
New Revision: 1228873

URL: http://svn.apache.org/viewvc?rev=1228873&view=rev
Log:
More consistent socket timeout handling by async protocol handlers

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExchange.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExchange.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExchange.java?rev=1228873&r1=1228872&r2=1228873&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExchange.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExchange.java
Sun Jan  8 15:50:13 2012
@@ -94,4 +94,14 @@ public interface HttpAsyncExchange {
      */
     void setCallback(Cancellable cancellable);
 
+    /**
+     * Sets timeout for this message exchange.
+     */
+    void setTimeout(int timeout);
+    
+    /**
+     * Returns timeout for this message exchange.
+     */
+    int getTimeout();
+    
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java?rev=1228873&r1=1228872&r2=1228873&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
Sun Jan  8 15:50:13 2012
@@ -46,6 +46,7 @@ import org.apache.http.nio.NHttpClientCo
 import org.apache.http.nio.NHttpClientEventHandler;
 import org.apache.http.nio.NHttpConnection;
 import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpProcessor;
@@ -74,6 +75,7 @@ import org.apache.http.protocol.HttpProc
  * class:
  * <ul>
  *  <li>{@link org.apache.http.params.CoreProtocolPNames#WAIT_FOR_CONTINUE}</li>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
  * </ul>
  *
  * @see HttpAsyncRequestExecutionHandler
@@ -150,6 +152,8 @@ public class HttpAsyncRequestExecutor im
             HttpRequest request = handler.generateRequest();
             context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
             
+            conn.setSocketTimeout(HttpConnectionParams.getSoTimeout(request.getParams()));
+            
             HttpProcessor httppocessor = handler.getHttpProcessor();
             httppocessor.process(request, context);
             

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java?rev=1228873&r1=1228872&r2=1228873&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
Sun Jan  8 15:50:13 2012
@@ -54,6 +54,7 @@ import org.apache.http.nio.NHttpServerCo
 import org.apache.http.nio.NHttpServerEventHandler;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.params.DefaultedHttpParams;
+import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
@@ -96,6 +97,12 @@ import org.apache.http.protocol.HttpProc
  * request handling to another service or a worker thread. HTTP response can
  * be submitted as a later a later point of time once response content becomes
  * available.
+ * <p/>
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ * <ul>
+ *  <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
+ * </ul>
  *
  * @since 4.2
  */
@@ -356,6 +363,7 @@ public class HttpAsyncService implements
                 }
                 closeHandlers(state);
                 state.reset();
+                conn.setSocketTimeout(HttpConnectionParams.getSoTimeout(this.params));
             }
         }
     }
@@ -557,6 +565,7 @@ public class HttpAsyncService implements
             }
             closeHandlers(state);
             state.reset();
+            conn.setSocketTimeout(HttpConnectionParams.getSoTimeout(this.params));
         } else {
             state.setResponseState(MessageState.BODY_STREAM);
         }
@@ -771,6 +780,14 @@ public class HttpAsyncService implements
             return this.completed;
         }
 
+        public void setTimeout(int timeout) {
+            this.conn.setSocketTimeout(timeout);
+        }
+
+        public int getTimeout() {
+            return this.conn.getSocketTimeout();
+        }
+
     }
 
 }



Mime
View raw message