currently I am struggeling with a little problem:
I want create FastCGI/CGI binding for the nekoVM. This is done by writing some clue C/C++ code that is loaded by the VM. I want to make the behaviour of my binding as compatible as possible with neko native API (mod_neko, mod_tora). With mod_neko it is possible to get all HTTP headers the client send.
As far as I know you can get HTTP headers with FastCGI only by calling getenv('header_name')
. To use this function you need to know the name of all headers.
My question: Is there any possibility to get all headers the client send?
You can use the externally-defined, null-terminated
environ
variable on most systems to get an array of all environment variables, which you could iterate to grab the headers you need (assuming FastCGI sets up the environment variables in a sensible way):See man 7 environ.
Apache's mod_fcgi puts all client http headers in the "FCGX_ParamArray" that you passed into FCGX_Accept (the main loop of the server app). That type is just a char**, with the common pattern "name, value, name, ..." for the strings. So, you just need a loop like this to get them all:
If you're using Apache and want to access all the static config ("httpd.conf") settings as well, they're passed in the "arge" environment block of main().
Be aware that not all clients will send all possible headers- CURL, for example, does not send an "accept" header.