chttpclient · Section 3
chttpcli_resp_header_count
NAME
chttpcli_resp_header_count - count the lines of a response header
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpclient.h>
size_t chttpcli_resp_header_count(const chttpcli_response *resp,
const char *name);
DESCRIPTION
This function returns how many lines of the response header block carry the given name, compared without regard to case. Each such line counts once whatever its value, an empty value included. Use it together with chttpcli_resp_header_at to read every occurrence of a header that a server can send more than once, such as Set-Cookie.
PARAMETERS
resp The response to query. It can be NULL, in which case the
function returns 0.
name The header name. It can be NULL, in which case the function
returns 0.
RETURN VALUE
The number of lines with that name, or 0 if there are none. A response from a streaming request keeps no headers, so it always gives 0.
NOTES
Only the response's header block counts. A trailer field of a chunked body is not a response header and is never counted here.
EXAMPLES
size_t n = chttpcli_resp_header_count(resp, "Set-Cookie"); for (size_t i = 0; i < n; i++) printf("cookie: %s\n", chttpcli_resp_header_at(resp, "Set-Cookie", i));
SEE ALSO
chttpcli_resp_header_at(3), chttpcli_resp_header(3), chttpcli_resp_free(3)