I have a C++ program acting as a CGI script, and I am currently using Cgicc to do some of the parsing and formatting for me (though it will probably be replaced at some point). When constructing my response, I use cgicc::HttpResponseHeader
, which will create me something like
HTTP/1.1 302 Found
Location: www.bla.com
This looks pretty standard to me. However, the Webserver chokes on that, giving me a
<...> malformed header from script. Bad header=HTTP/1.1 302 Found: script.cgi
I found out how to fix this:
HTTP/...
lineStatus: 302 Found
And in fact, that is exactly what cgicc::HttpRedirectHeader
does. I have now two questions:
HTTP/1.1 302 Found
not standard?cgicc::HttpResponseHeader
doing that? If it is, why does my webserver choke on it?Note I am not looking for ways to get around this, I know how to do that. I just want to understand whats going on.
Cheers Ole
The HTTP
line is standard HTTP, but not standard CGI.
Under CGI, the script uses a Status
header to communicate the status back to the web server, and the web server constructs the HTTP
response line from that status code.
Why cgicc
is constructing the HTTP
line I don't know - is it possible that you're not supposed to use that particular class in that context? Perhaps that class is only for use with nph
scripts? The documentation does kind of imply that - after describing the set of standard response classes, it says:
cgicc::HTTPResponseHeader is a more powerful, generic HTTP header class used to construct a full HTTP response.
The implication is that it's unusual to use that in a normal CGI script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With