Re: headers_out vs err_headers_out with temporary redirect 302

Torsten Förtsch <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
On 09/03/2012 03:59 PM, Anton Petrusevich wrote:
>> From the doc:
> === The difference between headers_out and err_headers_out, is that 
> the latter are printed even on error, and persist across internal 
> redirects (so the headers printed for ErrorDocument handlers will 
> have them). ===

Yes, that's a bit misleading. The point is what exactly is an "error" here.

I think what this statement means is that all of the internal redirect
functions, that is ap_internal_redirect, ap_internal_redirect_handler
and ap_internal_fast_redirect, contain code like this:

  new->err_headers_out = r->err_headers_out;

(The fast_redirect version does it via apr_table_overlay. But that's
only because it does not really create a new request. It simply
transmogrifies the current request to look like the new one.)

That means an ErrorDocument which is an internal redirect uses the
*same* error header table as the original request instead of a copy.

I think this is really all to it.

> It's still unclear to me what to use for temporary 302 redirects, 
> headers_out or err_headers_out? I tried headers_out and it works.
> But probably I am somewhere wrong?

The Location header (what I think you are talking about) is
special-cased in several locations in the code. It is taken from
headers_out or err_headers_out with headers_out taking precedence. I
think it's ap_send_error_response() that does it.

Torsten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.