KHTTP_FCGI_TEST(3)

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

πŸ’… KHTTP_FCGI_TEST(3) β€” test whether kcgi is using FastCGI ✨

okay so bestie, this is the KHTTP_FCGI_TEST(3) page from the Library Functions Manual. It's giving "tiny function, big main character energy," and it's here to answer one question: FastCGI or regular CGI? πŸ‘‘

🌸 NAME 🌸

khttp_fcgi_test β€” test whether kcgi is using FastCGI. That's it. That's the whole vibe check. πŸ’–

πŸ“š LIBRARY πŸ“š

library β€œlibkcgi” β€” yes bestie, it lives in libkcgi. 🫢

πŸ›  SYNOPSIS πŸ› 

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

int
khttp_fcgi_test();

πŸ” DESCRIPTION πŸ”

okay so khttp_fcgi_test() tests whether the kcgi(3) application is being run under a FastCGI or regular CGI socket. It is literally the vibe detector for your server situation. 🌈

Big caveat, no cap: this function may only be run prior to khttp_fcgi_init(3). Afterward, its behaviour is undefined. So call it before you init, or you're in undefined-behaviour territory and we don't do that here. πŸ’€

πŸ§ͺ EXAMPLES πŸ§ͺ

The following example starts an application in FastCGI or regular CGI mode depending upon the environment. Here's the code, copied with love and zero edits: πŸŽ€

int
main(void)
{
  struct kreq    req;
  struct kfcgi  *fcgi;
  enum kcgi_err  er;

  if (!khttp_fcgi_test()) {
    er = khttp_parse(&req, NULL, 0, NULL, 0, 0);
    if (er != KCGI_OK)
      err(1, "khttp_parse: %s", kcgi_strerror(er));
    /* Do something. */
    khttp_free(&req);
    return 0;
  }

  er = khttp_fcgi_init(&fcgi, NULL, 0, NULL, 0, 0);
  if (er != KCGI_OK)
    errx(1, "khttp_fcgi_init: %s", kcgi_strerror(er));
  for (;;) {
    er = khttp_fcgi_parse(fcgi, &req);
    if (er != KCGI_OK)
      err(1, "khttp_fcgi_parse: %s", kcgi_strerror(er));
    if (KCGI_EXIT == er) {
      khttp_free(&req);
      break;
    }
    /* Do something. */
    khttp_free(&req);
  }
  khttp_fcgi_free(fcgi);
  return 0;
}

πŸ‘€ SEE ALSO πŸ‘€

kcgi(3) β€” go read it, bestie. πŸ“–

✍️ AUTHORS ✍️

Written by Kristaps Dzonsons <kristaps@bsd.lv>. Iconic. πŸ‘‘


Signed, sealed, delivered: this is from Debian, dated $Mdocdate$, and it's the KHTTP_FCGI_TEST(3) page. Byeee! πŸ’…βœ¨πŸ¦‹

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