KHTTP_PUTS(3)
π KHTTP_PUTS β bestie, let's put some strings out there π
okay so real talk, this page is from the libkcgi library β yes, the "Library Functions Manual" one, she's iconic β and she's here to teach you how to shove a string into your kcgi output. no gatekeeping, let's go π«Ά
β¨ SYNOPSIS β¨
like, the vibe is:
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
enum kcgi_err
khttp_puts(struct kreq *req, const char *cp);
πΈ DESCRIPTION πΈ
So khttp_puts writes a NUL-terminated string, cp, into a kcgi(3) context req β and that context is literally the one you got from khttp_parse(3) or khttp_fcgi_parse(3), no cap.
If cp is NULL? It does nothing. Zero drama, it just vibes. π
Big important rule bestie: you should only call this after khttp_body(3). Like, body first, then strings. And heads up β unlike puts(3), it does NOT append a newline. So don't come crying about your missing \n, it's giving intentional. π
β οΈ And listen β ifkcgi_writer_disable(3)has already been invoked, this function willabort(3). Like, straight upabort(3). Not subtle. Do not.
π RETURN VALUES π
It returns an enum kcgi_err telling you the error state. Here's the whole cast of characters, no skips:
KCGI_OKβ Success! Not an error. She ate. πKCGI_ENOMEMβ Internal memory allocation failure. The memory said no. πKCGI_HUPβ The output connection has been terminated. For FastCGI connections, you should release the current connection withkhttp_free(3)and reenter the parse loop. That's the whole move. π¦KCGI_FORMβ The connection is still expecting headers withkhttp_head(3). This meanskhttp_body(3)did not return with success, or it was never invoked at all. For FastCGI connections, again: release the current connection withkhttp_free(3)and reenter the parse loop. Same ritual. β¨KCGI_SYSTEMβ Internal system error writing to the output stream. Lowest key ominous but okay. π
β SEE ALSO β
go read these, they're all part of the lore (iykyk):
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv>. iconic behavior, thank you for your service π«‘π
and that's the whole page bestie! this one's from the Debian build, dated $Mdocdate$, and she's KHTTP_PUTS(3) through and through β go forth and put some strings, but pls pls pls call khttp_body(3) first. mwah ππΈ
π¦ where this page comes from
- alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
- Copyright (c) 2020 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms