On Fri, Sep 17, 2010 at 11:13 AM, John Smith <[email protected]> wrote:
> I couldn't understand why I can't use backslash (%5C) symbol in URL?
>
> I've created file "\mytest.php" in my Linux box and sent request in
> Firefox http://localhost/\mytest.php
> and everything worked fine.
>
> But when I try use HttpClient I get this error
> "java.net.URISyntaxException: Illegal character in path at index"
> Browser can send request, HttpClient can't. Why did it happen?

Firefox does some "heuristic pre-processing" on URLs to escape invalid
characters for you before sending the request to the server.  This is
nice and user-friendly and all, but is fairly lax and not spec
compliant.  HttpClient is not a browser emulator and it is not part of
its mission to emulate all the conveniences, features, and quirks that
browser vendors fill their products with.

Anyway, I think you pretty much answered your own question.  Use %5C
in the URI instead of the literal backslash character.  It is not the
job of the URI class or even HttpClient to escape invalid characters
for you.  Perhaps take a look at java.net.URLEncoder as a tool to help
build valid URIs to use as input to HttpClient and related classes.

Mike

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

Reply via email to