KHTTP_PUTS(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’– 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 β€” if kcgi_writer_disable(3) has already been invoked, this function will abort(3). Like, straight up abort(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 with khttp_free(3) and reenter the parse loop. That's the whole move. πŸ¦‹
  • KCGI_FORM β€” The connection is still expecting headers with khttp_head(3). This means khttp_body(3) did not return with success, or it was never invoked at all. For FastCGI connections, again: release the current connection with khttp_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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms