hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manuel Castro Paliza <mcp...@tid.es>
Subject RE: Encoding of special characters in request URI
Date Thu, 10 Jul 2003 14:34:04 GMT
I've solved this problem (Spanish Characters ) with

  private static final String CHARSET="ISO-8859-15";

    }catch(org.apache.commons.httpclient.URI.DefaultCharsetChanged dcc){
      // CASE 1: the exception could be ignored, when it is set by user
      if (dcc.getReasonCode() == URI.DefaultCharsetChanged.PROTOCOL_CHARSET)
        // CASE 2: let user know the default protocol charset changed
        log.warn("Default Protocol Charset Changed to "+CHARSET);


-----Mensaje original-----
De: Martin Schnyder [mailto:martin.schnyder@insonic.com]
Enviado el: jueves, 10 de julio de 2003 16:23
Para: commons-httpclient-dev@jakarta.apache.org
Asunto: Encoding of special characters in request URI

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?

Martin Schnyder

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message