cURL / Mailing Lists / curl-library / Single Mail


Re: following redirects in libcurl

From: Richard Gray <>
Date: Fri, 17 Jun 2016 15:23:55 -0400

Daniel Stenberg wrote:
> On Fri, 17 Jun 2016, Richard Gray wrote:
>> I take it this is only valid if the operation got a redirect (HTTP 3xx)?
> Yes.
>> What if the operation was not redirected - do I need to check
>> Or does it cleanly return NULL in the non-redirect case? (Can I use this
>> option to simply check for a redirect by testing for NULL or non-NULL? )
> Yeps, it will return a NULL if there wasn't a redirect (and a Location:
> header). A proper thorough check would use the CURLINFO_RESPONSE_CODE as well.

Seems like CURLINFO_REDIRECT_COUNT would be the reliable check since it would
reflect actual redirect(s) happening: 3xx and location:. (Hmmm, out of
curiosity, if a broken server sent 3xx and no location header would that be
some sort of error condition?)

>> If CURLOPT_FOLLOWLOCATION is in effect, does the pointer still get set if a
>> redirect occurred or set NULL if no redirect??

So in general, is it correct to say that if a curl_easy_getinfo call returns
CURLE_OK but the requested info is not available because of options or
conditions during the transfer, the pointer gets set to NULL?


List admin:
Received on 2016-06-17