Fwd: [HttpClient] Adding fragment to the request URL

Hi Jonathan,

Seems like its impossible for us to include a plain # in the URL. We will
have to encode
it with %23.

Thanks,
Keith.

---------- Forwarded message ----------
From: Ortwin Glück <odi@odi.ch>
Date: Mar 13, 2007 4:05 PM
Subject: Re: [HttpClient] Adding fragment to the request URL
To: HttpComponents Project <httpcomponents-dev@jakarta.apache.org>

Keith,

It is illegal to include a plain # character in a HTTP URL. As you can
see from the BNF syntax notation below, the # character is not in the
list of characters that comprise an URL. This means you HAVE TO escape
it (or use a different character if you are in the position to decide that).

RFC 2396, section 4.1 clearly states:
"When a URI reference is used to perform a retrieval action on the
identified resource, the optional fragment identifier, separated from
the URI by a crosshatch ("#") character, consists of additional
reference information to be interpreted *BY THE USER AGENT* after the
retrieval action has been successfully completed.  As such, *IT IS NOT
PART OF A URI*, but is often used in conjunction with a URI."


RFC 2616, 3.2.2:
http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]

RFC 2396, Appendix A:
abs_path      = "/"  path_segments
path_segments = segment *( "/" segment )
segment       = *pchar *( ";" param )
pchar         = unreserved | escaped |
                 ":" | "@" | "&" | "=" | "+" | "$" | ","

query         = *uric
uric          = reserved | unreserved | escaped
reserved      = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                 "$" | ","
unreserved    = alphanum | mark
escaped       = "%" hex hex
mark          = "-" | "_" | "." | "!" | "~" | "*" | "'" |
                 "(" | ")"

Sorry to have no better news.

Ortwin


keith chapman wrote:
> Hi Ortwin,
>
> I wanted to send the # character over the wire as it is. Is there a way
> that
> I can do it? Or can I set the fragment to the httpMethod?
>
> Thnaks,
> Keith
>
> On 3/13/07, Ortwin Glück <odi@odi.ch> wrote:
>>
>> Keith,
>>
>> The # character is reserved to separate the fragment from the
>> query/path. The fragment is not intended to be sent over the wire. So if
>> you want to include such a character in an URI you should URL-escape it
>> with %23:
>>
>>
>>
http://localhost:8081/axis2/services/ProbeDataService.RawParameterEndpoint/RawParameter%23id
>>
>>
>>
>> Does that work for you?
>>
>> Ortwin
>>
>> keith chapman wrote:
>> > Hi,
>> >
>> > I want to send a http GET request to the followin url
>> >
>> >
>>
http://localhost:8081/axis2/services/ProbeDataService.RawParameterEndpoint/RawParameter#id
>>
>> >
>> >
>> > But i have to set a URI to the getMethod.
>> >
>> > I have the above as a URL. So I do the following
>> >
>> > getMethod.setURI(url.toString);
>> >
>> > This rips off the fragment part resulting in the following target URL
>> >
>> >
>>
http://localhost:8081/axis2/services/ProbeDataService.RawParameterEndpoint/RawParamete
>>
>> >
>> >
>> > How can I send a fragment in the url?
>> >
>> > Thanks,
>> > Keith
>> >
>>
>> --
>> [web]  http://www.odi.ch/
>> [blog] http://www.odi.ch/weblog/
>> [pgp]  key 0x81CF3416
>>         finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:
>> httpcomponents-dev-help@jakarta.apache.org
>>
>>
>
>

--
[web]  http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp]  key 0x81CF3416
        finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416

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



-- 
Keith Chapman
WSO2 Inc.
Oxygen for Web Services Developers.
http://wso2.org/

Received on Tuesday, 13 March 2007 10:52:27 UTC