[prev in list] [next in list] [prev in thread] [next in thread]
List: httpclient-users
Subject: Re: Backslash in URL
From: Mike Clark <mevanlc () gmail ! com>
Date: 2010-09-18 6:51:30
Message-ID: AANLkTinpwb3Hrh8O_MZeL3UTEwYPS9EgnAgBxdrEO+SV () mail ! gmail ! com
[Download RAW message or body]
On Fri, Sep 17, 2010 at 11:13 AM, John Smith <deaf.c0t@gmail.com> 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: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic