cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: A bug in libcurl (maybe?)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 5 Aug 2001 15:17:33 +0200 (MET DST)

On Sun, 15 Jul 2001, Jonathan Hseu wrote:

> The default action for CURLOPT_WRITEFUNCTION is to call its callback
> without necessarily a non-null CURLOPT_FILE.
>
> The way I act in this case is (in englishified C):
> If CURLOPT_FILE is NULL, return size * nmemb;
>
> However, the callback for CURLOPT_HEADERFUNCTION is _not_ called if
> CURLOPT_WRITEHEADER is NULL. Shouldn't it act similarly to
> CURLOPT_WRITEFUNCTION?

I agree with you, and I can only blame this current behaviour on sloppiness
and historichal reasons.

> I want CURLOPT_WRITEHEADER to be called when I give NULL for
> WRITEFUNCTION, because I only want to parse the header data instead of
> actually outputting it anywhere. Since I only need to parse a single
> line (a specific cookie line), I don't want to create a buffer of
> arbitrary size for this purpose, when no data will actually even enter
> the buffer anyways

Well, you can set a callback on CURLOPT_HEADERFUNCTION only, right? And if
you set CURLOPT_WRITEHEADER to be non-NULL too, you'll actually get the
callback. Isn't that what you want?

> Could what I said really be called a bug and,

I think so. The fix is very simple:

--- sendf.c 2001/05/31 13:50:28 1.24
+++ sendf.c 2001/08/05 13:14:36
@@ -230,7 +230,7 @@
       return CURLE_WRITE_ERROR;
     }
   }
- if((type & CLIENTWRITE_HEADER) && data->writeheader) {
+ if(type & CLIENTWRITE_HEADER) {
     /*
      * Write headers to the same callback or to the especially setup
      * header callback function (added after version 7.7.1).

(please let us know if this is fixes your problems)

> Is there anyway I can get CURLOPT_WRITEHEADER to be called even if
> WRITEFUNCTION is NULL without creating a buffer or outputting to any
> stream?

You don't have to create a buffer or a stream, all you need is to set it to
non-NULL. You could pass a constant or whatever. libcurl will do nothing but
pass that data to your callback, so you decide what to do with it.

> I know I can ignore certain streams in the callback function, but that
> seems unclean.

I agree, but it works as a work-around until the above patch is verified and
in use.

> Sorry for my weird, uncomprehensible wording =)

I think I understood it. If not, please correct me!

-- 
     Daniel Stenberg -- curl dude -- http://curl.haxx.se/
_______________________________________________
Curl-library mailing list
http://curl.haxx.se/libcurl/
Received on 2001-08-05

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET