cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_POSTREDIR and redirections

From: Jeff Pohlmeyer <yetanothergeek_at_gmail.com>
Date: Fri, 4 Sep 2009 02:07:40 -0500

On Sep 4, 2009, Rahul Rathi wrote:

> If i set the option CURLOPT_POSTREDIR, Curl will redirect
> the request to other URL returned by 301 response.
>
> Now, suppose that i made a request to URL xyz.com and its
> redirected to abc.com on 301 response. For all next requests,
> if i set the same url xyz.com using CURLOPT_URL option, will
> curl redirect on its own to abc.com ?
> Or the calling application is expected to keep track that xyz.com
> is getting redirected to abc.com ?

No, curl doesn't keep track of this.

If you want your application to behave that way, then you are responsible
to keep track of it, but keep in mind that some web sites might also check
the referer header and/or cookies, etc. and refuse to serve requests
that didn't originate from xyz.com.

 - Jeff
Received on 2009-09-04