cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Does libcurl POST to the current location, instead of the set URL?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 24 Jun 2009 19:58:41 +0200 (CEST)

On Wed, 24 Jun 2009, Matthias B. wrote:

> After I created the curl-Resource, I set curlopt_url, curlopt_post,
> curlopt_followlocation, curlopt_returntransfer, and curlopt_postfields.
>
> After the first execution, the script go in a for-loop. In this loop the
> curlopt_postfields gets changed, and curl gets executed again. But: It
> doesn't POST to the URL which was set before - it POST to the current
> Location - so I need to set the URL everytime.
>
> Why is that behavior? Is that documented?

You didn't really give us a lot of details here but it sounds like you get a
301, 302 or 303 redirect. You can use CURLOPT_POSTREDIR to alter how libcurl
acts on 301 and 302.

-- 
  / daniel.haxx.se
Received on 2009-06-24