curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Incorrect documentation of CURLOPT_HEADERFUNCTION

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 15 Feb 2018 23:10:56 +0100 (CET)

On Thu, 15 Feb 2018, Guido Berhoerster wrote:

>> The header callback will be called once for each header and only
>> complete header lines are passed on to the callback. Parsing headers
>> is very easy using this.
>
> This seems to be completely wrong, headers are chopped into chunks of
> CURL_MAX_WRITE_SIZE by Curl_client_chop_write(). The only way to distinguish
> a complete header seems to be a check whether the last character is a 0x0a.

The documentation is right here, the code is wrong. The code is supposed to
always deliver a full header or none at all. This is a bug.

> This also doesn't seem to be true, with libcurl 7.55.1 headers up to ~ 190K
> are read although I haven't checked where that limit actually comes from.

Please let me know how to reproduce that, I can't. I just wrote up a test case
with a header line that is longer than 102400 bytes and it ends up with:

  curl: (27) Avoided giant realloc for header (max is 102400)!

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2018-02-15