KHTTP_WRITE(3)

πŸ“¦
version 1.0.1 Β· 2 versions
, in alpine 3.24

πŸ’… KHTTP_WRITE(3) β€” bestie edition

okay so real quick, this is a page from the Library Functions Manual (yes that's the manual name, we stan a whole collection) and it's about khttp_write from libkcgi. buckle up πŸŽ€

🌸 LIBRARY

library β€œlibkcgi” β€” that's the one. the icon. the moment.


✨ SYNOPSIS

like, here's exactly what you type, no cap:

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

enum kcgi_err
khttp_write(struct kreq *req, const char *buf, size_t sz);

πŸ’– DESCRIPTION

okay so khttp_write writes binary data. you hand it buf (that's your data) and sz (that's how long it is, in bytes), and it shoves it into a kcgi(3) context req β€” and that req has to be one you already allocated with khttp_parse(3) or khttp_fcgi_parse(3). iykyk.

important timing note: you should only call this after khttp_body(3). like, order matters bestie. 🫢

and if buf is NULL or sz is zero? it just does nothing. literally nothing. no drama, no error, just vibes. πŸ’€

🚨 no but seriously: if kcgi_writer_disable(3) was invoked earlier, this function will abort(3). like, full process abort. that's not a drill, that's the actual behaviour. be careful out there.

πŸ”₯ RETURN VALUES

it returns an enum kcgi_err telling you the error state. here's the whole lineup:

  • KCGI_OK β€” success, bestie! πŸŽ‰ not an error. we love to see it.
  • KCGI_ENOMEM β€” internal memory allocation failure. the memory said no 😭.
  • KCGI_HUP β€” the output connection has been terminated. for FastCGI connections specifically, you should release the current connection with khttp_free(3) and reenter the parse loop. periodt.
  • KCGI_FORM β€” the connection is still expecting headers with khttp_head(3). this means khttp_body(3) either didn't return with success or was never invoked at all πŸ™ˆ. for FastCGI connections, again: release the current connection with khttp_free(3) and reenter the parse loop.
  • KCGI_SYSTEM β€” internal system error while writing to the output stream. rough. πŸ’”

πŸ‘‘ SEE ALSO

the whole friend group, go read them too:


🌈 AUTHORS

Written by Kristaps Dzonsons <kristaps@bsd.lv>. king behaviour honestly.


and that's the whole page! πŸ’œ huge shoutout to Debian for shipping it, this is from the $Mdocdate$ build, and yes it's KHTTP_WRITE(3) all the way at the bottom too β€” go forth and write your HTTP content data, bestie, you're gonna slay πŸ¦‹βœ¨

πŸ“¦ 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