cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: http status code early?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 4 Apr 2003 08:47:16 +0200 (CEST)

On Thu, 3 Apr 2003 RBramante_at_on.com wrote:

> I also needed to know the HTTP response code prior to receiving the content
> (and hence before curl_easy_peform() returned).
>
> The way I did it was to setup for the CURLOPT_HEADERFUNCTION callback, and
> in there parse the response code out of the header manually. Then I
> stuffed that value away in a place accessible from the other callbacks so
> they knew how to behave based on the response.
>
> Kind of hacky, but it was the only way I could see to do it. I suppose
> this might be a feature that is desirable to others, maybe a more standard
> solution could be identified.

Reading the code, it sure looks as if curl_easy_getinfo(curl,
CURLINFO_HTTP_CODE, ...) will return the HTTP code whenever you call it, even
if curl_easy_peform() hasn't returned yet.

If we want to support this kind of behavior (I mean documented as well) we
better make sure the function return an error code or something well defined
if the HTTP code hasn't yet been recevied. Currently I believe it will return
the previous value until the new one is set, which is bound to confuse
applications...

I'm open to syggestions.

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
Received on 2003-04-04