hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1477547 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
Date Tue, 30 Apr 2013 10:45:19 GMT
Author: olegk
Date: Tue Apr 30 10:45:18 2013
New Revision: 1477547

URL: http://svn.apache.org/r1477547
Log:
Basic connection pool implementations to perform default port resolution for HTTP and HTTPS
schemes

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java?rev=1477547&r1=1477546&r2=1477547&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
Tue Apr 30 10:45:18 2013
@@ -71,7 +71,16 @@ public class BasicNIOConnPool extends Ab
         }
 
         public SocketAddress resolveRemoteAddress(final HttpHost host) {
-            return new InetSocketAddress(host.getHostName(), host.getPort());
+            final String hostname = host.getHostName();
+            int port = host.getPort();
+            if (port == -1) {
+                if (host.getSchemeName().equalsIgnoreCase("http")) {
+                    port = 80;
+                } else if (host.getSchemeName().equalsIgnoreCase("https")) {
+                    port = 443;
+                }
+            }
+            return new InetSocketAddress(hostname, port);
         }
 
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java?rev=1477547&r1=1477546&r2=1477547&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
Tue Apr 30 10:45:18 2013
@@ -149,8 +149,18 @@ public class BasicConnFactory implements
         if (socket == null) {
             throw new IOException(scheme + " scheme is not supported");
         }
+        final String hostname = host.getHostName();
+        int port = host.getPort();
+        if (port == -1) {
+            if (host.getSchemeName().equalsIgnoreCase("http")) {
+                port = 80;
+            } else if (host.getSchemeName().equalsIgnoreCase("https")) {
+                port = 443;
+            }
+        }
+
         socket.setSoTimeout(this.sconfig.getSoTimeout());
-        socket.connect(new InetSocketAddress(host.getHostName(), host.getPort()), this.connectTimeout);
+        socket.connect(new InetSocketAddress(hostname, port), this.connectTimeout);
         socket.setTcpNoDelay(this.sconfig.isTcpNoDelay());
         final int linger = this.sconfig.getSoLinger();
         if (linger >= 0) {



Mime
View raw message