hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [11/35] httpcomponents-core git commit: merged connection debugging for NIO from trunk
Date Tue, 09 May 2017 20:03:40 GMT
merged connection debugging for NIO from trunk


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1142757
13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/8eef5fbd
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/8eef5fbd
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/8eef5fbd

Branch: refs/heads/4.1.x
Commit: 8eef5fbd880c13b4da42e1768309b72032ed87b6
Parents: 886e6aa
Author: Asankha Chamath Perera <asankha@apache.org>
Authored: Mon Jul 4 18:46:13 2011 +0000
Committer: Asankha Chamath Perera <asankha@apache.org>
Committed: Mon Jul 4 18:46:13 2011 +0000

----------------------------------------------------------------------
 .../impl/nio/DefaultNHttpClientConnection.java  | 27 ++++++++++++++++++++
 .../impl/nio/DefaultNHttpServerConnection.java  | 27 ++++++++++++++++++++
 .../http/impl/nio/NHttpConnectionBase.java      | 13 ++++------
 .../http/impl/nio/reactor/IOSessionImpl.java    | 26 +++++++++++++++++--
 4 files changed, 83 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index e66fa29..c7abf7a 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -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,30 @@ public class DefaultNHttpClientConnection
         return this.request != null;
     }
 
+    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();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index a511c8d..59592de 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -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,30 @@ public class DefaultNHttpServerConnection
         return this.response != null;
     }
 
+    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();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index 1cfd500..4e2b192 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -412,14 +412,11 @@ public class NHttpConnectionBase
 
     @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();
+        StringBuilder buf = new StringBuilder();
+        buf.append(this.session.getLocalAddress())
+            .append("<->")
+            .append(this.session.getRemoteAddress());
+        return buf.toString();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8eef5fbd/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 31e6682..dbc4d99 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -28,6 +28,7 @@
 package org.apache.http.impl.nio.reactor;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.nio.channels.ByteChannel;
 import java.nio.channels.Channel;
@@ -290,7 +291,7 @@ public class IOSessionImpl implements IOSession {
         this.lastAccessTime = now;
     }
 
-    private static void formatOps(final StringBuffer buffer, int ops) {
+    private static void formatOps(final StringBuilder buffer, int ops) {
         if ((ops & SelectionKey.OP_READ) > 0) {
             buffer.append('r');
         }
@@ -307,7 +308,28 @@ public class IOSessionImpl implements IOSession {
 
     @Override
     public synchronized String toString() {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
+
+        if (getRemoteAddress() instanceof InetSocketAddress &&
+            getLocalAddress()  instanceof InetSocketAddress) {
+
+            final InetSocketAddress remote = ((InetSocketAddress) getRemoteAddress());
+            final InetSocketAddress local  = ((InetSocketAddress) getLocalAddress());
+
+            buffer.append(local.getAddress().getHostAddress())
+            .append(':')
+            .append(local.getPort())
+            .append("<->")
+            .append(remote.getAddress().getHostAddress())
+            .append(':')
+            .append(remote.getPort());
+
+        } else {
+            buffer.append(getLocalAddress())
+            .append("<->")
+            .append(getRemoteAddress());
+        }
+
         buffer.append("[");
         switch (this.status) {
         case ACTIVE:


Mime
View raw message