curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Documentation of CURLOPT_HEADERFUNCTION

From: Christopher Head via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 26 Aug 2019 10:09:47 -0700

Hi folks,
I needed to collect certain data from custom HTTP headers. It seems that the proper way to accomplish this is CURLOPT_HEADERFUNCTION. When experimenting with it, there are three things I was surprised by, that did not seem to be obvious from the documentation:

(1) The data blocks passed to the header function include newline characters at the end. I was not expecting this: I normally think of a header as being a single line, and the newline character(s) as separating two headers but being part of neither.

(2) The status line is included. I was not expecting this: perhaps incorrectly, I normally think of an HTTP reply as comprising a status line, zero or more headers, a blank line, and the body, so I do not think of the status line as a header itself.

(3) The blank line before the body is included. See (2) for why this surprised me.

Does anyone else think it’s worth clarifying the documentation regarding any or all of the above? I could try writing such a PR if useful, though I have never used Curl for anything other than HTTP(S), nor used it for HTTP/2, so I may not produce text that is entirely protocol agnostic.

-- 
Christopher Head
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-08-26