curl-library
Re: how to send POST request when follow location
Date: Tue, 12 Jul 2011 23:38:14 +0200 (CEST)
On Tue, 12 Jul 2011, xinyi huang wrote:
> I have send a POST request, and set CURLOPT_FOLLOWLOCATION to be TRUE.
> The peer http url will location to a new https url.
> Output information shows that curl automatically send a new GET request to
> the new url.
It depends entirely on the HTTP response code the server returns. libcurl is
made to (by default) mimic how browsers treat them, which for 301 and 302 that
it will change from POST to GET - contrary to what RFC2616 says we should.
You can alter the behavior for both 301 and 302 by the use of the
CURLOPT_POSTREDIR option.
> char error[2048] = {0};
> curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error);
CURL_ERROR_SIZE might be clever to use for the error buffer as it will never
be larger!
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2011-07-12