cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: HTTP post problem with quoted string as param

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 2 Dec 2011 01:39:45 -0800

On Thu, Dec 01, 2011 at 03:48:08PM +0530, Vinoth raj wrote:
> I have problem in sending a parameter through HTTP post.
> I want to send a parameter with double quotes (say "Quote 3").
> I converted the string into UTF-8 as %e2%80%9cQuote%203%e2%80%9d and did a HTTP
> post to server.
> When I receive the request parameter in servlet (using request.getParemeter) I
> get %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D
> In servlet side I am using UTF-8 too. But what is not clear to me is how
> %e2%80%9cQuote%203%e2%80%9d changed to
> %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D ( which on decoding gives
> junkQuotejunk)

It turns out that if you treat the first string (%e2%80%9cQ...) as ISO-8859-1
and convert that to UTF-8, you get the second string (%C3%A2%C2%80%C2%9C...).
So, something is already doing that UTF-8 conversion for you. See what happens
if you don't convert the original parameter.

> Also, the curlopt errorbuffer did not report any error.
> I don't want to send the parameter as %22Quote%203%22 but only as
> %e2%80%9cQuote%203%e2%80%9d

The error buffer will only show an error if an error occurred. In this case,
curl happily sends the parameter and the server clearly has no issue (at
the HTTP level, anyway) in receiving it.

> In short, I want send the encoded string %e2%80%9cQuote%203%e2%80%9d and
> receive at server end as such.

It's likely the server doing that UTF-8 conversion for you. Perhaps you need
to specify a different charset=utf-8 parameter in the Content-Type header to
stop the server from converting the paramater again.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-02