Apache mod_fcgi puts all the HTTP client headers in the "FCGX_ParamArray" that you passed to FCGX_Accept (the main server application loop). This type is just char **, with a common pattern "name, value, name, ..." for strings. So you just need a loop like this to get them all:
std :: map & ltstd :: string, std :: string & gt hdrs;
std :: string name = 0;
char * val = 0;
int i;
// "envp" is the FCGX_ParamArray you passed into FCGX_Accept (...)
for (i = 0; envp [i]! = NULL; i + = 2) {
name = envp [i];
val = envp [i + 1];
if (val! = NULL) {
hdrs [name] = string (val);
}
else {
hdrs [name] = "";
}
}
If you use Apache and want to access all the static configuration settings ("httpd.conf"), they are passed in the "arge" main () environment block.
int main (int argc, char ** argv, char ** arge) {
....
}
Remember that not all clients will send all possible headers. For example, CURL does not send an accept header.
Zack yezek
source share