hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Rocci (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-1039) AbstractHttpClient.determineTarget does not recognize target host correctly
Date Wed, 05 Jan 2011 11:11:47 GMT

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

Marco Rocci commented on HTTPCLIENT-1039:
-----------------------------------------

I was thinking... if the determineTarget method really has to do this host extraction itself...
shouldn't it use:
     requestURI.getRawSchemeSpecificPart()
instead of:
     requestURI.getSchemeSpecificPart()

At least that should solve this type of problem, right?

Workarounds seem difficult. The called method is private in AbstractHttpClient... and the
calling method is public final.

Marco

> AbstractHttpClient.determineTarget does not recognize target host correctly
> ---------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1039
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1039
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.1 Beta1
>            Reporter: Marco Rocci
>             Fix For: 4.1.0
>
>
> I am trying to execute an HttpGet with the following URI:
> "http://www.foo.foo/doSomething.html?url=http://www.bar.bar/doSomethingElse.html"
> This leads to UnknownHostException
> Going through the internal code, the problem seems to be in the AbstractHttpClient.determineTarget
method:
>             String ssp = requestURI.getSchemeSpecificPart();
>             ssp = ssp.substring(2, ssp.length()); //remove "//" prefix
>             int end = ssp.indexOf(':') > 0 ? ssp.indexOf(':') :
>                     ssp.indexOf('/') > 0 ? ssp.indexOf('/') :
>                     ssp.indexOf('?') > 0 ? ssp.indexOf('?') : ssp.length();
>             String host = ssp.substring(0, end);
> This code sets the target host to "www.foo.foo/doSomething.html?url=http" instead of
"www.foo.foo". This obviously breaks the execution not far down the line... DefaultClientConnectionOperator.resolveHostname
throws an UnknownHostException.
> FWIW the AbstractHttpClient.determineTarget method actually has access to the request
URI object, which correctly states that the host is "www.foo.foo".
> So why does it try to extract the host from the scheme specific part anyway?
> I hope this is useful... and if there is any workaround please let me know, as I'm stuck
on this one.
> Marco

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message