cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How can i get the answer from a post ?

From: Nikolai Kondrashov <Nikolai.Kondrashov_at_oktetlabs.ru>
Date: Tue, 29 Jul 2008 11:08:24 +0400

>> Are you sure that the site doesn't answer with 30x response? Because in
>> that case you could receive no data and you may need to use
>> CURLOPT_FOLLOWLOCATION option to get to the actual response.
> I found the ans :
> After i do the easy_perform that send the POST i need to switch to GET
> (curl_easy_setopt (CURL * curl_handler, CURLOPT_HTTPGET, 1L) ) and the
> do another easy perform.

This looks perfectly like a POST/Redirect/GET pattern
[http://en.wikipedia.org/wiki/Post/Redirect/Get] usage. I.e. the server
responds to your POST with 30x code, redirecting you to the same page. So
you could have achieved the same result simply by adding
CURLOPT_FOLLOWLOCATION to your POST and not doing additional GET by
yourself. Like this:

curl_easy_setopt(curl_handler, CURLOPT_FOLLOWLOCATION, 1L);

Sincerely,
Nick
Received on 2008-07-29