I have a CGI script that prints the following on stdout:
print "Status: 302 Redirect\n";
print "Server: Apache-Coyote/1.1\n";
print "Location: $redirect\n";
print "Content-Length: 0\n";
print "Date: $date\n\n";
Where $redirect and $date are reasonable values. What Apache2 actually sends also includes a Content-Type: header (text/plain). I've commented out the DefaultType in the server configuration file.
I'm trying to debug a downstream problem that arises when no Content-Type: header is sent. So what magic incantation do I have to perform to prevent Apache2 from adding the content type header?
According to my (admittedly brief) reading of server/protocol.c and server/core.c, you cannot.
It always defaults to DefaultType (text/plain by default) if that header is not present.
Even if we delete the Content-Type header from the request via the "Header unset Content-Type" directive, apache regenerates the Content-Type header from another field of the request structure. Therefore, we first force that other field to a reserved value, in order to prevent the header regeneration, then we remove the Content-Type via the "Header unset" directive.
For apache2.2:
Header set Content-Type none
Header unset Content-Type
For apache2.4:
Header set Content-Type ""
Header unset Content-Type
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