harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r503570 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/net/Socket.java org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
Date Mon, 05 Feb 2007 06:58:31 GMT
Author: mloenko
Date: Sun Feb  4 22:58:31 2007
New Revision: 503570

URL: http://svn.apache.org/viewvc?view=rev&rev=503570
Log:
fixed HARMONY-3113
[classlib][luni] can't http connect thru a proxy
(no regression test since the bug is confihuratrion-dependent)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java?view=diff&rev=503570&r1=503569&r2=503570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java Sun Feb
 4 22:58:31 2007
@@ -912,7 +912,7 @@
         InetSocketAddress inetAddr = (InetSocketAddress) remoteAddr;
         InetAddress addr;
         if ((addr = inetAddr.getAddress()) == null) {
-            throw new UnknownHostException(Msg.getString("K0317"));//$NON-NLS-1$
+            throw new UnknownHostException(Msg.getString("K0317", remoteAddr));//$NON-NLS-1$
         }
         int port = inetAddr.getPort();
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java?view=diff&rev=503570&r1=503569&r2=503570
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
Sun Feb  4 22:58:31 2007
@@ -34,6 +34,7 @@
 import java.net.ProxySelector;
 import java.net.ResponseCache;
 import java.net.Socket;
+import java.net.SocketAddress;
 import java.net.SocketPermission;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -635,7 +636,23 @@
                     getConnectTimeout());
         } else if (proxy.type() == Proxy.Type.HTTP) {
             socket = new Socket();
-            socket.connect(proxy.address(), getConnectTimeout());
+
+            SocketAddress proxyAddr = proxy.address();
+
+            if (!(proxyAddr instanceof InetSocketAddress)) {
+                throw new IllegalArgumentException(Msg.getString(
+                        "K0316", proxyAddr.getClass())); //$NON-NLS-1$
+            }
+
+            InetSocketAddress iProxyAddr = (InetSocketAddress) proxyAddr;
+
+            if( iProxyAddr.getAddress() == null ) {
+                // Resolve proxy, see HARMONY-3113
+                socket.connect(new InetSocketAddress((iProxyAddr.getHostName()),
+                    iProxyAddr.getPort()), getConnectTimeout());
+            } else {
+                socket.connect(iProxyAddr, getConnectTimeout());
+            }
         } else {
             // using SOCKS proxy
             socket = new Socket(proxy);



Mime
View raw message