hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r1130988 - in /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio: DefaultNHttpClientConnection.java DefaultNHttpServerConnection.java NHttpConnectionBase.java
Date Fri, 03 Jun 2011 11:15:06 GMT
Author: asankha
Date: Fri Jun  3 11:15:06 2011
New Revision: 1130988

URL: http://svn.apache.org/viewvc?rev=1130988&view=rev
Log:
enhance the toString() method of NIO connections to show the direction, and to remove the
starting "/" from being shown on a IP:PORT pair

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

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=1130988&r1=1130987&r2=1130988&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
Fri Jun  3 11:15:06 2011
@@ -28,6 +28,7 @@
 package org.apache.http.impl.nio;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -254,4 +255,31 @@ public class DefaultNHttpClientConnectio
         return this.request != null;
     }
 
+    @Override
+    public String toString() {
+        StringBuilder buf = new StringBuilder();
+
+        if (this.session.getRemoteAddress() instanceof InetSocketAddress &&
+            this.session.getLocalAddress()  instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
+            final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
+
+            buf.append(local.getAddress().getHostAddress())
+            .append(':')
+            .append(local.getPort())
+            .append("->")
+            .append(remote.getAddress().getHostAddress())
+            .append(':')
+            .append(remote.getPort());
+
+        } else {
+            buf.append(this.session.getLocalAddress())
+            .append("->")
+            .append(this.session.getRemoteAddress());
+        }
+
+        return buf.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=1130988&r1=1130987&r2=1130988&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
Fri Jun  3 11:15:06 2011
@@ -28,6 +28,7 @@
 package org.apache.http.impl.nio;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
@@ -256,4 +257,31 @@ public class DefaultNHttpServerConnectio
         return this.response != null;
     }
 
+    @Override
+    public String toString() {
+        StringBuilder buf = new StringBuilder();
+
+        if (this.session.getRemoteAddress() instanceof InetSocketAddress &&
+            this.session.getLocalAddress()  instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) this.session.getRemoteAddress());
+            final InetSocketAddress local  = ((InetSocketAddress) this.session.getLocalAddress());
+
+            buf.append(remote.getAddress().getHostAddress())
+            .append(':')
+            .append(remote.getPort())
+            .append("->")
+            .append(local.getAddress().getHostAddress())
+            .append(':')
+            .append(local.getPort());
+
+        } else {
+            buf.append(this.session.getRemoteAddress())
+            .append("->")
+            .append(this.session.getLocalAddress());
+        }
+
+        return buf.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=1130988&r1=1130987&r2=1130988&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
Fri Jun  3 11:15:06 2011
@@ -425,7 +425,7 @@ public class NHttpConnectionBase
     public String toString() {
         StringBuilder buf = new StringBuilder();
         buf.append(this.session.getLocalAddress())
-            .append("->")
+            .append("<->")
             .append(this.session.getRemoteAddress());
         return buf.toString();
     }



Mime
View raw message