hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1480) Provide a convenience method to parse a proxy with format localhost:port
Date Fri, 14 Mar 2014 11:33:43 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13934894#comment-13934894

Oleg Kalnichevski commented on HTTPCLIENT-1480:


Your implementation must also be able to deal gracefully with crazy input. It currently can
deal with sane input only. For one, it should catch and handle NumberFormatException instead
of propagating it to the caller and risking killing the thread. 

Assert.assertEquals(new HttpHost("localho]st", 1), Request.parseProxy("localho]st:1"));
Assert.assertEquals(new HttpHost("[1fff:0:1fff:1fff::1fff]:huh", -1), Request.parseProxy("[1fff:0:1fff:1fff::1fff]:huh"));
Assert.assertEquals(new HttpHost("[1fff:0:1fff:1fff::1fff]: 8080", -1), Request.parseProxy("[1fff:0:1fff:1fff::1fff]:


> Provide a convenience method to parse a proxy with format localhost:port
> ------------------------------------------------------------------------
>                 Key: HTTPCLIENT-1480
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1480
>             Project: HttpComponents HttpClient
>          Issue Type: New Feature
>          Components: Fluent HC
>    Affects Versions: 4.3.3
>            Reporter: Remis
>            Priority: Minor
>             Fix For: 4.4 Alpha1
>         Attachments: HTTPCLIENT-1480.patch
> This issue relates to HTTPCORE-365 (which was the original issue about this topic). What
I actually want to achieve is to have a convenience method to allow us to call the viaProxy()
method with a String as parameter. E.g.:
> Request.Get(uri).viaProxy("localhost:8080").execute();
> Notes about the attached patch:
> - I did not know where to put the new method "protected static HttpHost parseProxy(String
proxy)" so I put it inside Request.java
> - the parseProxy(String) is static because it is a utility class, so you can move to
a more "appropriate place" and anyone can use it for other use-cases.
> - following the suggestion of Gary Gregory, I made it compatible with IPv6 (following
links below):
> -- http://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers
> -- http://stackoverflow.com/questions/186829/ipv6-and-ports
> -- http://serverfault.com/questions/205793/how-can-one-distinguish-the-host-and-the-port-in-an-ipv6-url
> Hope to see it in 4.3.4 :-).

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message