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

Roland Weber commented on HTTPCLIENT-727:
-----------------------------------------

Hello Marc,

that argument to the constructor is _not_ just a path. You are calling a 
constructor that expects a _URI_ string as argument, which may or may not have 
a host section. That string gets parsed by the constructor, according to the 
rules of some RFC.
The URI string you are giving to the constructor starts with //. That tells the 
parser that there is no scheme (protocol), but there is a host. Compare these 
two examples:

//hc.apache.org/index.html
//js/includes/foo.js

Do you see the problem now? If you want just a path, then make sure that the 
argument you are passing to the constructor starts with a _single_ slash, since 
that indicates the start of the path.

The example http://my.site//foo/bla.html should work with HttpClient's URI 
class, too. There is a scheme (protocol) "http", followed by a colon and the // 
that indicates the host section. The first / after the host section starts the 
path. Everything's peachy. Just don't omit the part before //foo.

Browser to all kinds of stuff to handle broken input and guess something useful 
from it. HttpClient is not a browser:
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners#head-a110969063be34fcd964aeba55ae23bea12ac232

HttpClient 4.0 uses the java.net.URI class, where bugs can be reported to Sun. 
You'll find that this class also interprets a leading // as the start of the 
host section, because that's what the RFC says.

hope this helps,
  Roland


> Misbehaviour of URI.getEscapedPath() with uri containing double slash like 
> //js/includes/foo.js
> -----------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-727
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-727
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 3.1 Final
>            Reporter: Marc Guillemot
>
> public void testURI_getEscapedPath() throws Exception {
>       URI uri = new URI("//js/includes/foo.js", false);
>       assertEquals("//js/includes/foo.js", uri.toString()); // passes
>       assertEquals("//js/includes/foo.js", uri.getEscapedPath()); // fails
> }

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to