How can I * prevent * Apache2 from setting the Content-Type header?

I have a CGI script that outputs the following to 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. In fact, the uploaded Apache2 also includes the Content-Type: (text / plain) header. I commented on DefaultType in the server configuration file.

I am trying to debug a downstream problem that occurs when sending a Content-Type: header. So, what magic spell needs to be done so that Apache2 does not add a content type header?

+5
source share
6 answers

According to my (admittedly short) reading of server / protocol.c and server / core.c you cannot.

DefaultType ( /plain ), .

+3

RemoveType .

<Files defaulttypenone.txt>
DefaultType None 
</Files>
<Files removetype.txt>
RemoveType .txt
</Files>
<Files forcetype.txt>
ForceType None
</Files>

, . /plain.

+1

, , , "" netcat - .

, 100% , .

+1

:

ResponseHeader unset Content-Type
0

Apache,

Header unset Content-Type

, !

0

Even if we remove the Content-Type header from the request using the "Header unset Content-Type" directive, apache will regenerate the Content-Type header from another field in the request structure. Therefore, we first force the other field to a reserved value to prevent the header from being regenerated, then we remove the Content-Type using 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
0
source

All Articles