|
NAMEkhttp_body , khttp_body_compress
—
close the HTTP header sequence for kcgi
LIBRARYlibrary “libkcgi”SYNOPSIS#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
enum kcgi_err
enum kcgi_err
DESCRIPTIONThekhttp_body () and
khttp_body_compress () functions terminate the zero or
more
khttp_head(3)
calls for a
kcgi(3)
context req. After these functions, invoking
khttp_head(3)
or invoking khttp_body () or
khttp_body_compress () again results in undefined
behaviour.
The The RETURN VALUESThekhttp_body () and
khttp_body_compress () functions return an
enum kcgi_err indicating the error state.
EXAMPLESWrite out an HTTP header sequence and text content with automatic compression detection. Assume that r is a pointer to a struct kreq successfully initialised by khttp_parse(3).khttp_head(r, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]); khttp_head(r, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[KMIME_TEXT_PLAIN]); khttp_body(r); khttp_puts(r, "Hello, world!\n"); To explicitly disable compression: khttp_head(r, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]); khttp_head(r, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[KMIME_TEXT_PLAIN]); khttp_body_compress(r, 0); khttp_puts(r, "Hello, world!\n"); To disable compression, but emit a compressed file: khttp_head(r, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]); khttp_head(r, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[KMIME_TEXT_PLAIN]); khttp_head(r, kresps[KRESP_CONTENT_ENCODING], "%s", "gzip"); khttp_body_compress(r, 0); khttp_template(r, NULL, "compressed.txt.gz"); SEE ALSOkcgi(3), khttp_head(3), zlib(3)AUTHORSThekhttp_body () function was written by
Kristaps Dzonsons
<kristaps@bsd.lv>.
Visit the GSP FreeBSD Man Page Interface. |