Hello,
I have a mod_perl (Apache 1.3.33, mod_perl 1.29) handler which returns
HTTP error codes on several conditions, and uses a custom_response() to
set a custom body. The custom body is XML (this is a middleware component
and errors are read by machines, not humans), so I'd like to send a
"Content-Type: text/xml" header.
This code doesn't work as expected:
sub handler {
my $r = shift;
# This header makes it to the error output
$r->err_header_out('X-Message-Source' => 'test mod_perl handler');
# This one does not, it is overridden
$r->err_header_out('Content-Type' => 'text/xml');
$r->custom_response('<?xml version="1.0"?><test/>');
return BAD_REQUEST;
}
The X-Message-Source header makes it to the resulting 400 Bad Request
error response, but the Content-Type header has been changed to
"text/html; charset=iso-8859-1" sometime after the custom response.
I tried a number of variants (for example, using all three of
content_type(), header_out(), and err_header_out()), and none of them
worked. I poked through the code a little bit but looks like
custom_response() literally just overwrites a default error page string
with the custom one, so the magic code to set error headers is elsewhere.
Oddly enough when I was experimenting with setting Content-Length for a
custom_response() I found that it was necessary to use both header_out()
and err_header_out(); omitting either would cause no Content-Length header
to be sent, but including both would work.
Can anybody shed any light on this issue for me? Thanks in advance!
Humbly,
Andrew
----------------------------------------------------------------
Andrew Ho [EMAIL PROTECTED]
Staff Engineer 650-930-9062
Tellme Networks, Inc. http://www.tellme.com/
----------------------------------------------------------------