C Collections

chttpserver · Section 3

chttpsvr_req_header

chttpsvr_req_header - look up a request header

C Collections (libccollections, -lccollections)

#include <ccollections/chttpserver.h>
 
const char *chttpsvr_req_header(const chttpsvr_req *req,
                                 const char *name);

Returns the value of the request header called name, or NULL when the
request has no such header.  The name is compared without regard to
case, and for a header that appears more than once you get the last
value.
 
The pointer is valid until the handler call returns.

The trailer fields of a chunked request body (RFC 7230 4.1.2) are not
request headers, and this function never returns one.  It answers
only from the header block of the request, so on buffered and
streaming routes alike a trailer field of any name reads as absent.
 
Trailer fields arrive after the server has routed the request and
the middleware has run, and on a buffered route also after the
server has read the header block.  If trailers were indexed together
with the headers, a client could send a trailer that replaces a
header set by an upstream proxy (such as X-Forwarded-For, or the
identity header of an authentication gateway) on a request that the
server has already committed to.  The server has no accessor for
trailers at all, and a deployment that needs trailer semantics should
terminate the trailers in front of it.

chttpsvr_req_method(3), chttpsvr_req_path(3), chttpsvr_req_read(3)