[
https://issues.apache.org/jira/browse/HTTPCLIENT-1309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13565906#comment-13565906
]
Oleg Kalnichevski commented on HTTPCLIENT-1309:
-----------------------------------------------
This snippet works for me.
---
DefaultHttpClient client = new DefaultHttpClient();
HttpHost target = new HttpHost("127.0.0.1", 8080);
HttpGet get = new HttpGet("http://127.0.0.1:8080/RELEASE-NOTES.txt");
HttpContext context = new BasicHttpContext();
HttpResponse response = client.execute(target, get, context);
EntityUtils.consumeQuietly(response.getEntity());
---
---
[DEBUG] BasicClientConnectionManager - Get connection for route
{}->http://127.0.0.1:8080
[DEBUG] DefaultClientConnectionOperator - Connecting to 127.0.0.1:8080
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] RequestTargetAuthentication - Target auth state: UNCHALLENGED
[DEBUG] RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: GET /RELEASE-NOTES.txt
HTTP/1.1
[DEBUG] headers - >> GET /RELEASE-NOTES.txt HTTP/1.1
[DEBUG] headers - >> Host: 127.0.0.1:8080
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> User-Agent: Apache-HttpClient/4.2.3 (java 1.5)
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
[DEBUG] headers - << HTTP/1.1 200 OK
[DEBUG] headers - << Server: Apache-Coyote/1.1
[DEBUG] headers - << Accept-Ranges: bytes
[DEBUG] headers - << ETag: W/"7317-1242256504000"
[DEBUG] headers - << Last-Modified: Wed, 13 May 2009 23:15:04 GMT
[DEBUG] headers - << Content-Type: text/plain
[DEBUG] headers - << Content-Length: 7317
[DEBUG] headers - << Date: Tue, 29 Jan 2013 22:44:49 GMT
[DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely
[DEBUG] BasicClientConnectionManager - Releasing connection
org.apache.http.impl.conn.ManagedClientConnectionImpl@3f77b3cd
[DEBUG] BasicClientConnectionManager - Connection can be kept alive indefinitely
---
Oleg
> UnknownHostException if DefaultHttpClient asked to handle HttpRequest whose
> host name includes a port
> -----------------------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-1309
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1309
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpConn
> Affects Versions: 4.2.3
> Environment: Mac OS X 10.6.8 HttpClient 4.2.1 - field above won't
> let me put in 4.2.1
> Reporter: Ian Blavins
> Priority: Minor
>
> If a DefaultHttpClient is passed, in its .execute(target, request, context)
> method call, an HttpRequest whose host name field contains a port suffix (eg
> 192.168.0.102:8080) then SystemDefaultDnsResolver will try to resolve the
> host name plus port and gets an UnknownHostException:
> java.net.UnknownHostException: 192.168.0.102:8080.
> There appears to be a work around and that is to download the source of
> SystemDefaultDnsResolver, make the obvious change to remove any port and then
> rebuild httpclient-4.2.1.jar. (There is probably an easier way to present the
> revised SystemDefaultDnsResolver since its intended to be replaced by the
> user developer but I haven't discovered it)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]