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

Andreas Wundsam commented on HTTPCLIENT-1795:
---------------------------------------------

Hi Mike,

thanks for looking into this!
{quote}
The problem appears to be with InetAddress.getAllByName and not with the 
HttpGet.
Is this correct?
{quote}

I think the issue isn't with {{InetAddress.getAllByName}} as much; 
InetAddress.getAllByName takes an IPv6 literal, which doesn't require the '%' 
to be quoted.

The issue is with the URL decoding -- when using a IPv6 literal with a zone ID 
as the hostname _in an URL_, the RFC states that the "%" sign should be URL 
encoded.

So IMHO, the best place to address the problem would be at the point where 
http-client goes from a URL to a decoded hostname. When decoding the hostname 
part from the URL {{%25}} would also have to be decoded as {{%}}. 

Java's URI.getHost() unfortunately does not specify whether the host literal is 
decoded; and looking at the code it at least in Java9 does not seem to decode 
it.

Btw; an equivalent bug was reported for the JDK with HttpURLConnection: 
https://bugs.openjdk.java.net/browse/JDK-8027308; that bug was closed, but it 
looks like the fix in Java9 only fixes part of the reported issue.

Let me know if this helps?

> Http Client does not support RFC-compliant quoted IPv6 Link-Local host 
> literals
> -------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1795
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1795
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (async)
>    Affects Versions: 4.5.2
>            Reporter: Andreas Wundsam
>              Labels: stuck, volunteers-wanted
>             Fix For: Stuck
>
>
> [RFC 6874|https://tools.ietf.org/html/rfc6874] states that, when constructing 
> a URL with an LLv6 literal, the {{%}} sign that prefixes the ZoneID must be 
> quoted as {{%25}}. E.g., the LLv6 address 
> {{fe80::221:b7ff:fe8a:57d5%en4}} should be specified as 
> {{scheme://[fe80::221:b7ff:fe8a:57d5%25en4]/...}} in a URL.
> httpclient does not seem to support quoted host literals:
> Example:
> {code}
>         Request.Get("http://[fe80::221:b7ff:fe8a:57d5%25en4]/";)
>                 .connectTimeout(1000)
>                 .socketTimeout(1000)
>                 .execute().returnContent().asString();
> {code}
> results in
> {noformat}
> java.net.UnknownHostException: no such interface 25en4
>       at java.net.Inet6Address.initstr(Inet6Address.java:487)
>       at java.net.Inet6Address.<init>(Inet6Address.java:408)
>       at java.net.InetAddress.getAllByName(InetAddress.java:1181)
>       at java.net.InetAddress.getAllByName(InetAddress.java:1126)
>       at 
> org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
>       at 
> org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:111)
>       at 
> org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
>       at 
> org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
>       at 
> org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
>       at 
> org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
>       at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
>       at 
> org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
>       at 
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
>       at 
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
>       at 
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
>       at 
> org.apache.http.client.fluent.Request.internalExecute(Request.java:173)
>       at org.apache.http.client.fluent.Request.execute(Request.java:177)
>       at Test.name(Test.java:12)
> [...]
> {noformat}
> It appears that httpclient directly passes the host literal 
> {{[fe80::221:b7ff:fe8a:57d5%25en4]}} to the Java standard method 
> {{InetAddress.getAllByName(host)}}, which does not support the URL quoting 
> that RFC 6874 prescribes.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to