KHTTP_FCGI_TEST(3)
π 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
- Copyright (c) 2015, 2021 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