views:

102

answers:

1

I am using Cgicc , which has some methods to extract specific request headers, e.g. getUserAgent would return "User-Agent" header.

Is there a generic method that can return an arbitrary header value, e.g. something like

getHeaderValue("x-my-header");

Is there a way to do this using cgicc? and if cannot be done with cgicc, how else can I extract a custom header from the request in c++?

+1  A: 

No, cgicc does not support this direcly. However, it is just a wrapper around CGI. http://en.wikipedia.org/wiki/Common_Gateway_Interface and it uses "getenv" in CgiInput class to extract all information provided by the web server.

So if the client send some header that is not supported directly by CgiCC but does supported by the web server (lets say Accept-Encoding:) that you just need to read apropriate environment variable getenv("HTTP_ACCEPT_ENCODING")

But it should be supported by web server you are working with

EDIT: actually according CGI RFC http://www.ietf.org/rfc/rfc3875.txt web server should provide enviroment variable for your example: HTTP_X_MY_HEADER

Artyom