hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r909384 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
Date Fri, 12 Feb 2010 12:42:46 GMT
Author: olegk
Date: Fri Feb 12 12:42:45 2010
New Revision: 909384

URL: http://svn.apache.org/viewvc?rev=909384&view=rev
Log:
HTTPCLIENT-911: improved handling of invalid request uris (host name containing an underscore)

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java?rev=909384&r1=909383&r2=909384&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
Fri Feb 12 12:42:45 2010
@@ -624,17 +624,21 @@
         return execute(determineTarget(request), request, context);
     }
 
-    private HttpHost determineTarget(HttpUriRequest request) {
+    private HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException
{
         // A null target may be acceptable if there is a default target.
         // Otherwise, the null target is detected in the director.
         HttpHost target = null;
 
         URI requestURI = request.getURI();
         if (requestURI.isAbsolute()) {
-            target = new HttpHost(
-                    requestURI.getHost(),
-                    requestURI.getPort(),
-                    requestURI.getScheme());
+            String host = requestURI.getHost();
+            int port = requestURI.getPort();
+            String scheme = requestURI.getScheme();
+            if (host == null) {
+                throw new ClientProtocolException(
+                        "URI does not specify a valid host name: " + requestURI);
+            }
+            target = new HttpHost(host, port, scheme);
         }
         return target;
     }



Mime
View raw message