KHTTP_HEAD(3) BSD Library Functions Manual KHTTP_HEAD(3)NAMEkhttp_head — emit HTTP headers for kcgi
LIBRARY
library “libkcgi”
SYNOPSIS
#include <stdint.h>
#include <kcgi.h>
void
khttp_head(struct kreq *req, const char *key, const char *fmt, ...);
DESCRIPTION
The khttp_head function emits HTTP headers for a kcgi(3) context allo‐
cated by khttp_parse(3). This may only be invoked prior to
khttp_body(3); if not, its behaviour is undefined. The key value should
be an HTTP response pair key. The fmt string and variable arguments,
which follow printf(3) syntax, should be the HTTP response pair value.
The kresps global array, defined in khttp_parse(3), provides indexed HTTP
response keys for the default enum kresp. Use it!
See khttp_body(3) for a discussion on the “Content-Encoding” header: do
not specify this header before doing so!
EXAMPLES
To emit a session cookie (no expiration date) with key “foo” and value
“bar” for the global path, one may invoke the following. Assume that r
is a context allocated by khttp_parse(3).
khttp_head(r, kresps[KRESP_SET_COOKIE], "%s", "foo=bar; path=/");
SEE ALSOkcgi(3), khttp_body(3), khttp_parse(3)AUTHORS
The khttp_head function was written by Kristaps Dzonsons
⟨kristaps@bsd.lv⟩.
CAVEATS
Long header values (≥ 1024 B) will be truncated.
BSD May 13, 2024 BSD