You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Anton Petrusevich <ca...@casus.us> on 2012/09/03 15:59:52 UTC

headers_out vs err_headers_out with temporary redirect 302

Hello, 

>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).
===

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?
--
Anton Petrusevich

Re: headers_out vs err_headers_out with temporary redirect 302

Posted by Torsten Förtsch <to...@gmx.net>.
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