hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1053669 - in /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio: DefaultNHttpClientConnection.java DefaultNHttpServerConnection.java NHttpConnectionBase.java reactor/IOSessionImpl.java
Date Wed, 29 Dec 2010 16:32:00 GMT
Author: olegk
Date: Wed Dec 29 16:32:00 2010
New Revision: 1053669

URL: http://svn.apache.org/viewvc?rev=1053669&view=rev
Log:
Added protected #bind method allowing connections to be upgraded (bound to another I/O session);
improved #toString() method for default HTTP connection implementations

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?rev=1053669&r1=1053668&r2=1053669&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
Wed Dec 29 16:32:00 2010
@@ -254,17 +254,4 @@ public class DefaultNHttpClientConnectio
         return this.request != null;
     }
 
-    @Override
-    public String toString() {
-        StringBuffer buffer = new StringBuffer();
-        buffer.append("[");
-        if (isOpen()) {
-            buffer.append(this.session.getRemoteAddress());
-        } else {
-            buffer.append("closed");
-        }
-        buffer.append("]");
-        return buffer.toString();
-    }
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java?rev=1053669&r1=1053668&r2=1053669&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
Wed Dec 29 16:32:00 2010
@@ -256,17 +256,4 @@ public class DefaultNHttpServerConnectio
         return this.response != null;
     }
 
-    @Override
-    public String toString() {
-        StringBuffer buffer = new StringBuffer();
-        buffer.append("[");
-        if (isOpen()) {
-            buffer.append(this.session.getRemoteAddress());
-        } else {
-            buffer.append("closed");
-        }
-        buffer.append("]");
-        return buffer.toString();
-    }
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java?rev=1053669&r1=1053668&r2=1053669&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
Wed Dec 29 16:32:00 2010
@@ -89,8 +89,6 @@ import org.apache.http.protocol.HttpCont
 public class NHttpConnectionBase
         implements NHttpConnection, HttpInetConnection, SessionBufferStatus {
 
-    protected final HttpContext context;
-
     protected final ContentLengthStrategy incomingContentStrategy;
     protected final ContentLengthStrategy outgoingContentStrategy;
 
@@ -101,7 +99,9 @@ public class NHttpConnectionBase
     protected final HttpTransportMetricsImpl outTransportMetrics;
     protected final HttpConnectionMetricsImpl connMetrics;
 
+    protected HttpContext context;
     protected IOSession session;
+    protected SocketAddress remote;
     protected volatile ContentDecoder contentDecoder;
     protected volatile boolean hasBufferedInput;
     protected volatile ContentEncoder contentEncoder;
@@ -129,8 +129,6 @@ public class NHttpConnectionBase
         if (params == null) {
             throw new IllegalArgumentException("HTTP params may not be null");
         }
-        this.session = session;
-        this.context = new SessionHttpContext(session);
 
         int buffersize = HttpConnectionParams.getSocketBufferSize(params);
         int linebuffersize = buffersize;
@@ -150,11 +148,28 @@ public class NHttpConnectionBase
                 this.inTransportMetrics,
                 this.outTransportMetrics);
 
-        this.session.setBufferStatus(this);
-        this.session.setEvent(EventMask.READ);
+        setSession(session);
         this.status = ACTIVE;
     }
 
+    private void setSession(final IOSession session) {
+        this.session = session;
+        this.context = new SessionHttpContext(this.session);
+        this.session.setBufferStatus(this);
+        this.remote = this.session.getRemoteAddress();
+    }
+
+    /**
+     * @since 4.1.1
+     */
+    protected void bind(final IOSession session) {
+        if (session == null) {
+            throw new IllegalArgumentException("I/O session may not be null");
+        }
+        this.session.setBufferStatus(null);
+        setSession(session);
+    }
+
     /**
      * @since 4.1
      */
@@ -406,4 +421,16 @@ public class NHttpConnectionBase
         return this.connMetrics;
     }
 
+    @Override
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append("[");
+        buffer.append(this.remote);
+        if (this.status == CLOSED) {
+            buffer.append("(closed)");
+        }
+        buffer.append("]");
+        return buffer.toString();
+    }
+
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java?rev=1053669&r1=1053668&r2=1053669&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
Wed Dec 29 16:32:00 2010
@@ -272,7 +272,7 @@ public class IOSessionImpl implements IO
         StringBuffer buffer = new StringBuffer();
         buffer.append("[");
         if (this.key.isValid()) {
-            buffer.append("interested ops: ");
+            buffer.append("interest ops: ");
             formatOps(buffer, this.interestOpsCallback != null ?
                     this.currentEventMask : this.key.interestOps());
             buffer.append("; ready ops: ");



Mime
View raw message