views:

217

answers:

4

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?

A: 

You can try with the directive:

ResponseHeader unset Content-Type
Maurice Perry
No, although I can use header add to add new header (so I know header processing is being performed), header unset content-type has no effect.
Norm
A: 

As I read the Apache docs in question, what you want may actually be

Header unset Content-Type

Hope this does it!

dsalo
No, that didn't work. I think ResponseHeader became Header in Apache2.
Norm
+1  A: 

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.

ceri
Ah. Grumble. I guess I'll have to setup some other web server in order to debug my client. (I'm trying to fix a bug report that says my code falls over if the server doesn't send a Content-Type at all.)
Norm
Will the CGI run on the command-line? Just run the above script out of inetd perhaps?
ceri
A: 

RemoveType will stop sending a content type with the resource.

Addendum

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

Tested on my own server, these three solutions and none worked. They all returned text/plain.

karlcow
<Files defaulttypenone.txt>DefaultType None </Files><Files removetype.txt>RemoveType .txt</Files><Files forcetype.txt>ForceType None</Files>Tested on my own server, this three solutions and none worked. They all returned text/plain.
karlcow