chttpclient · Section 3
chttpcli_resp_header
NAME
chttpcli_resp_header - look up a response header by name
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpclient.h>
const char *chttpcli_resp_header(const chttpcli_response *resp,
const char *name);
DESCRIPTION
This function returns the value of the named response header, or NULL if the response has no such header. The lookup ignores case, because the response stores every header name in lowercase and the function lowercases your name before it looks it up. A server can send the same header name on several lines. For such a name the function returns the combined value that RFC 9110 section 5.3 defines, which is every value in wire order joined with ", ". Set-Cookie is the only exception: RFC 9110 section 5.3 and RFC 6265 section 3 forbid combining it (a cookie value can hold a comma of its own), so for "set-cookie" you get the first occurrence. chttpcli_resp_header_count and chttpcli_resp_header_at give you each occurrence separately. The response's headers map holds the same value for each name as this function returns. The returned pointer stays valid until chttpcli_resp_free is called.
PARAMETERS
resp The response to query. It can be NULL, in which case the
function returns NULL.
name The header name. It can be NULL, in which case the function
returns NULL.
RETURN VALUE
A pointer to the header's value string, or NULL if the header is not there.
NOTES
The map behind this function is built from the response's header block only. A chunked body can carry trailer fields (RFC 7230 4.1.2), which the client parses and validates, but those are not response headers. So a trailer field of any name reads as absent here, and it can never replace a header that the server actually sent.
SEE ALSO
chttpcli_resp_header_count(3), chttpcli_resp_header_at(3), chttpcli_resp_free(3)