You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Geoffrey Young <gy...@laserlink.net> on 2000/06/02 16:47:57 UTC

err_headers_out Q

hi all...

this simple script:

#!/usr/bin/perl

my $r = shift;
$r->err_headers_out->add('Set-Cookie' => "name=error");
warn "pre headers_out: " . $r->headers_out->get('Set-Cookie');

$r->send_http_header('text/plain');

warn "post headers_out: " . $r->headers_out->get('Set-Cookie');
print "done";

yields:
pre headers_out:  at /usr/local/apache/perl-bin/err.cgi line 7.
post headers_out: name=error at /usr/local/apache/perl-bin/err.cgi line 9.

and sets the cookie...

I was initially trying to create a PerlInitHandler to put a cookie in
err_headers_out, which I would expect to be set only if other handlers down
the line error out, but it was being set every request.

am I misunderstanding err_headers_out, or is send_http_header misbehaving? 

--Geoff

Re: err_headers_out Q

Posted by Drew Taylor <dt...@vialogix.com>.
Doug MacEachern wrote:
> 
> see http_protocol.c:send_http_header():
> 
>     if (!ap_is_empty_table(r->err_headers_out))
>         r->headers_out = ap_overlay_tables(r->pool, r->err_headers_out,
>                                         r->headers_out);
Basically, what the code above says is that when calling
send_http_header(), if the headers_out table is not empty, add them to
the outgoing headers. Am I correct? If so, what is the rational behind
this? I thought that err_headers_out were only sent if an error occured.
I would have made the same assumption as Geoff.

-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/

Re: err_headers_out Q

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 2 Jun 2000, Geoffrey Young wrote:

> hi all...
> 
> this simple script:
> 
> #!/usr/bin/perl
> 
> my $r = shift;
> $r->err_headers_out->add('Set-Cookie' => "name=error");
> warn "pre headers_out: " . $r->headers_out->get('Set-Cookie');
> 
> $r->send_http_header('text/plain');
> 
> warn "post headers_out: " . $r->headers_out->get('Set-Cookie');
> print "done";
> 
> yields:
> pre headers_out:  at /usr/local/apache/perl-bin/err.cgi line 7.
> post headers_out: name=error at /usr/local/apache/perl-bin/err.cgi line 9.
> 
> and sets the cookie...
> 
> I was initially trying to create a PerlInitHandler to put a cookie in
> err_headers_out, which I would expect to be set only if other handlers down
> the line error out, but it was being set every request.
> 
> am I misunderstanding err_headers_out, or is send_http_header misbehaving? 

see http_protocol.c:send_http_header():

    if (!ap_is_empty_table(r->err_headers_out))
        r->headers_out = ap_overlay_tables(r->pool, r->err_headers_out,
                                        r->headers_out);