Hi, Geoffrey!

> your procedure is correct.  well, except that you can't do what you
> want :)
> 
> take a look at http_protocol.c - 
> 
> 'r->content_type = "text/html; charset=iso-8859-1";' is hardcoded
> in ap_send_error_response(), so it's an apache thing and not a
> mod_perl thing...
Absolutely true to my surprise. That means you can't return proper
content-type and content-encoding with non-OK codes, Apache will
rewrite it for you anyway, which is too human-oriented and imho
should be corrected. I ended up generating usual successful response
with custom status (which is 500 in my case):

  $r->status($self->response->code);
  $self->response->headers->scan(sub { $r->header_out(@_) });
  $r->send_http_header(join '; ', $self->response->content_type);
  $r->print($self->response->content);
  &Apache::Constants::OK;

Probably worth mentioning in FAQ or somewhere. It took quite a bit of
my time.

Best wishes, Paul.

--- Geoffrey Young <[EMAIL PROTECTED]> wrote:
> 
> 
> > -----Original Message-----
> > From: Paul Kulchenko [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 30, 2001 2:53 AM
> > To: Stas Bekman
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [Problem] Can't return Content-type with
> SERVER_ERROR
> > 
> 
> [snip]
> 
> > 
> > it's the same as to use err_headers_out as far as I understand.
> What
> > is the general procedure to generate custom content-type along
> with
> > SERVER_ERROR?
> > 
> > sub handler {
> >   ...
> >   $r->content_type('text/xml; charset=utf-8');
> >   $r->custom_response($self->response->code,
> >                       $self->response->content);
> >   $self->response->code;
> > }
> > 
> > doesn't work if '$self->response->code' is 500. mod_perl
> overrides my
> > content-type with text/html.
> > 
> 
> your procedure is correct.  well, except that you can't do what you
> want :)
> 
> take a look at http_protocol.c - 
> 
> 'r->content_type = "text/html; charset=iso-8859-1";' is hardcoded
> in
> ap_send_error_response(), so it's an apache thing and not a
> mod_perl
> thing...
> 
> HTH
> 
> --Geoff
>  


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply via email to