cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Mike Crowe <mac_at_mcrowe.com>
Date: Mon, 9 Jun 2008 11:41:56 +0100

On Thu, 5 Jun 2008, I 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.
 
On Fri, Jun 06, 2008 at 11:54:44PM +0200, Daniel Stenberg wrote:
> 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.

Good point. I hadn't considered that.

> 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)

Ahem, yes. :-)

> 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.

Some sort of pre-body callback function (that unlike detecting the end
of headers in the HEADERFUNCTION would be guaranteed to be called only
once per high level request even in the face of the multiple attempts
required for authentication) is the only alternative I could come up
with.

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

That's the type of thing I was looking for (and had missed for some
reason - I think I was looking from the wrong angle).

Thanks for your help.

Mike.
Received on 2008-06-09