Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access URL with double slash with HttpClient

I'm doing a request on another server like this:

HttpGet req = new HttpGet("http://example.com//foo");
new DefaultHttpClient().execute(req);

However, HttpClient changes example.com//foo to example.com/foo, so the other server (which is not mine) doesn't understand the request.

How can I fix this?

like image 465
Bart van Heukelom Avatar asked Sep 23 '11 14:09

Bart van Heukelom


1 Answers

A double-slash is not a legal in the path section of a URI (see RFC2396, sections 3.2, 3.4). The '//' sequence has a defined meaning in the URI, it denotes the authority component (server).

I realize this does not answer your question but the HttpClient is, in fact, behaving in accordance with the HTTP and URL standards. The server your are reading from is not. This appears to be previously reported (https://issues.apache.org/jira/browse/HTTPCLIENT-727) and discarded by the HttpClient team.

like image 158
pap Avatar answered Sep 22 '22 13:09

pap