cURL / Mailing Lists / curl-library / Single Mail


Re: Knowing when to report response code when using HTTP AUTH

From: Daniel Stenberg <>
Date: Fri, 6 Jun 2008 23:54:44 +0200 (CEST)

On Thu, 5 Jun 2008, Mike Crowe wrote:

> The alternative, which I believe should work, would be to call
> curl_easy_getinfo(CURLINFO_RESPONSE_CODE) the first time the READFUNCTION
> (or other body function) callback is called and abort then. This just seems
> a little ugly because I either have to redundantly check every time or keep
> track of whether it is the first time the body callback has been called.

First, aborting the transfer may not always be the fastest way since it'll
also kill persistant connections and that can be more valuable than preventing
to download a certain amount of data.

Then, I don't see how you can make the code work much differently than
aborting your first call to the _write_ callback (not read) if the conditions
are telling you that. Any other solution would force your code to have even
more knowledge about the peculiarities of the HTTP protocols and I at
least would consider that a worse option.

Of course CURLOPT_FAILONERROR might already give you what you're looking for.

Received on 2008-06-07