curl / Mailing Lists / curl-library / Single Mail


Incorrect documentation of CURLOPT_HEADERFUNCTION

From: Guido Berhoerster <>
Date: Thu, 15 Feb 2018 16:54:27 +0100

The documentation for CURLOPT_HEADERFUNCTION states:

> 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.
I don't think that most client code is aware of this, naive
implementations e.g. check for either a single 0x0a or a 0x0d 0x0a in
order to delimit responses. IMO this makes dealing with headers more
tedious than it already is, so I think it would be better to fix the
code to match the implementation rather than the other way around.

> A complete HTTP header that is passed to this function can be up to
> CURL_MAX_HTTP_HEADER (100K) bytes.

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.

Guido Berhoerster
Received on 2018-02-15