Hello Martin,

This is a good question, one that I am not positive I know the answer to. The HTTP request line (containing the query params) must be US-ASCII. That I am sure of. The catch is that form urlencoding strings makes them ASCII, regardless of the original charset. So HttpMethod.setQueryString(NameValuePair[]) is assuming that the inputs(query params) are ASCII when really only the output(encoded params) should be ASCII.

The question is how does one determine, on the client and the server, what the charset of the query params is? The request charset can be specified with the Content-Type header, but this is meant to apply to the request entity, not the headers. I have a feeling that we should probably be using the content charset anyway. My reasoning here is that an HTML form can be sent via a GET(query params) or POST(post content). In both cases the content must be form urlencoded and my feeling is that it should be done the same for both.

What does everyone else think?

Mike

Martin Schnyder wrote:
When I use the GetMethod class to send text with special characters (German
Umlaute "äöü") in the request parameters, the special characters are not
encoded correctly. This happens when I use method
HttpMethodBase.setQueryString(NameValuePair[] params)
to set the query parameters.

I saw that Release 2.0 Beta 2 fixed that with bug fix 20481. Special
characters are now encoded differently but still wrong, as far as I can see.

Method HttpMethodBase.setQueryString(NameValuePair[]) calls
formUrlEncode(params, HttpConstants.HTTP_ELEMENT_CHARSET) to encode the
parameters. The value of HTTP_ELEMENT_CHARSET is US-ASCII. When I change the
charset to HttpConstants.DEFAULT_CONTENT_CHARSET (which is ISO-8859-1), the
German "Umlaute" are encoded correctly. I checked that with the code in CVS
HEAD. Is this a bug or should really only the US-ASCII characters be
supported in a request URI?

Regards,
Martin Schnyder


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to