chttpserver · Section 3
chttpsvr_resp_add_header
NAME
chttpsvr_resp_add_header - add one more field of a response header
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpserver.h>
ccol_retval chttpsvr_resp_add_header(chttpsvr_resp *resp,
const char *name,
const char *value);
DESCRIPTION
Adds one "name:value" field line to the response, after all the fields already set. Where chttpsvr_resp_set_header(3) replaces, this function keeps the existing fields of the same name, so a response can carry two Set-Cookie lines, for example. The fields go on the wire in the order of the calls. name and value are validated exactly as chttpsvr_resp_set_header(3) validates them, with the same results. name must be a non-empty RFC 7230 token, value must hold no byte below 0x20 other than the tab and no 0x7F, "Transfer-Encoding" is refused, and a "Content-Length" value must be a number. "Connection", "Content-Length" and "Date" carry at most one field in any response. For these names the function acts like chttpsvr_resp_set_header(3) and replaces the value; that page says how the server treats each of them.
RETURN VALUE
ccol_success on success. ccol_invalid_args in the cases that chttpsvr_resp_set_header(3) lists. ccol_not_enough_memory when the underlying allocation fails. A failed call changes nothing in the response.
EXAMPLES
chttpsvr_resp_add_header(resp, "Set-Cookie", "a=1; Path=/"); chttpsvr_resp_add_header(resp, "Set-Cookie", "b=2; Path=/");