cURL / Mailing Lists / curl-users / Single Mail

curl-users

RE: Curl re-uses old POST data in GET requests on same handle (7.12.3)

From: Cyrill Osterwalder <cyrill.osterwalder_at_seclutions.com>
Date: Tue, 11 Jan 2005 14:48:25 +0100

Sorry for the reply issue, I'll remember that next time and I'll also move
to the libcurl list.

>... and you make it a GET again by using CURLOPT_HTTPGET? Can
>you provide us
>with an example source code that shows this behavior?

In 7.12.2 it was enough to do the following on an existing handle to switch
to a GET request and it worked even after previous POSTs:
curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, NULL);

The same section is not good enough anymore in 7.12.3. I have to set the
other options explicitly as described in my posting.

But since you clearly specify the options to be sticky it is probably wanted
behaviour and I was just lucky that my initial code worked. The behaviour
still seems to have changed and that might be good to know for some people
(in the libcurl list probably ;-)).

Best regards,

Cyrill

> -----Original Message-----
> From: Daniel Stenberg [mailto:daniel-curl_at_haxx.se]
> Sent: Dienstag, 11. Januar 2005 14:39
> To: curl tool talk
> Cc: 'Cyrill Osterwalder'
> Subject: Re: Curl re-uses old POST data in GET requests on
> same handle (7.12.3)
>
>
> On Tue, 11 Jan 2005, Cyrill Osterwalder wrote:
>
> (Please don't start new threads by replying to an old mail.
> Also note that
> libcurl issues are better discussed on the libcurl mailing
> list where you'll
> reach more libcurl users/hackers.)
>
> > There is a new behavior in curl 7.12.3 that I just
> recognized. If operating
> > with the same curl handle it seems that with the new
> version 7.12.3 curl
> > re-uses data from a previous POST request again in a new
> request even if the
> > new one is a GET request.
>
> ... and you make it a GET again by using CURLOPT_HTTPGET? Can
> you provide us
> with an example source code that shows this behavior?
>
> > That seems to happen whenever the handle deals with a POST
> request. It even
> > re-uses the old content length which results in erroneous
> behaviour in most
> > cases (GET request with content length makes server wait
> for data that is
> > not coming).
>
> curl handles have "sticky" options. Everything you set
> remains set until you
> change it again.
>
> > Is this new behaviour intended and do I have to reset POST
> relevant fields
> > manually on the handle before reusing it or is it a bug?
>
> You need to set the request back to GET, otherwise it'll
> continue using POST.
>
> --
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>
Received on 2005-01-11