cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: POST to GET question

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 11 Jun 2007 13:00:53 +0200 (CEST)

On Mon, 11 Jun 2007, Andrey Ivanov wrote:

> I've noticed a strange curl behaviour, the whole thing works in most cases
> but this is odd anyway. The problem appears when I'm trying to make a GET
> request just after I make POST using the same handle. Here is slightly
> modified curl/docs/examples/debug.c:

You should consider using the curl-library mailing list for questions and talk
related to the library...

> /* make POST */
> res = curl_easy_perform(curl);
>
> curl_easy_setopt(curl, CURLOPT_POST, 0);
> /* just to be sure */
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "");
> /* make GET */
> res = curl_easy_perform(curl);

No, this is not how you switch from POST to get. Here you just try to blank
the posted data but there's no "opposite" of doing POST so this doesn't
automatically enable GET.

You want to use CURLOPT_HTTPGET there.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-06-11