FCGI_STARTFILTERDATA(3)

πŸ’– FCGI_StartFilterData β€” the fcgi_stdio compatibility library glow-up πŸ’–

okay bestie, sit down, hydrate, because we're talking about FCGI_StartFilterData(3) from the fcgi_stdio compatibility library. it's giving "let me read my filter input from stdin, finally" energy, and honestly? iconic.


✨ SYNOPSIS ✨

#include "fcgi_stdio.h"

int
FCGI_StartFilterData(void);

that's it. that's the whole vibe. one function, zero arguments, maximum main character energy 🫢


🌸 DESCRIPTION 🌸

so like, this is the function that lets a FastCGI Filter application start reading its filter input data from stdin. that's the whole job. she's a simple girl. πŸ’…

but β€” and this is the important part, no cap β€” before you can call FCGI_StartFilterData, two things have to be true:

  • your FastCGI application needs to have been invoked in the Filter role, like literally getenv("FCGI_ROLE") == "FILTER"
  • you should have read stdin all the way to EOF, consuming the entire FCGI_STDIN data stream πŸ“

if you did all that, then the call to FCGI_StartFilterData positions stdin at the start of FCGI_DATA. slay. that's the dream. ✨

⚠️ but if the preconditions are NOT met (e.g. your app has not read stdin to EOF), FCGI_StartFilterData returns a negative result, and your application will get EOF on attempts to read from stdin. that's the cursed timeline. we don't want that. 😭

okay so how do you even know how many bytes you've got coming? the application can determine the number of bytes available on FCGI_DATA by doing this lil thing:

atoi(getenv("FCGI_DATA_LENGTH"))

and listen β€” if fewer than that many bytes get delivered on stdin after calling FCGI_StartFilterData, your application should perform an application-specific error response. and if your application normally makes an update? most likely it should abort the update. do not proceed. do not pass go. 🚫

also!! you can find out the last modification time of the filter input data by doing:

getenv("FCGI_DATA_LAST_MOD")

which means your application can do caching based on last modification time. obsessed with a queen who caches. 🧚


πŸŽ€ RETURN VALUES πŸŽ€

  • 0 β€” for a successful call, periodt πŸ’–
  • < 0 β€” for error, and we do not perceive it πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹


πŸ‘‘ HISTORY πŸ‘‘

Copyright (c) 1996 Open Market, Inc.

See the file "LICENSE" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.


and that's the whole page bestie β€” brought to you by the $Id: FCGI_StartFilterData.3,v 1.1.1.1 1997/09/16 15:36:26 stanleyg Exp $ era, so yeah, she's vintage, she's a classic, she's lowkey older than everyone in the group chat and still ate πŸ’œ go read your stdin to EOF and live your truth ✨🌈