You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tofu Optimist <to...@yahoo.com> on 2003/10/18 16:31:00 UTC

err_headers_out vs headers_out

[1] When should one use err_headers_out and when
should one use headers_out?  I know when redirecting
the former is used for Set-Cookie and the later is
used for Location (Practical Mod Perl p. 756), but
what about cache control, p3p, etc?  (code fragment
below)

[2] Also, what is the difference between the 'set' and
'add' methods?  (Where might I find docs for the
mod_perl methods?)

Many thanks --

TO



    my $cookie_out = CGI::Cookie->new(
        -name    => $cookiename,
        -value   => $cookievalue,
        -path    => '/',
        -expires => '+14d',
    );

    $r->err_headers_out->add( 'Set-Cookie' =>
$cookie_out );

    my $P3P = q(CP="CURa ADMa DEVa OUR COM NAV INT CNT
STA NID DSP NOI COR");
    $r->err_headers_out->add( 'P3P' => $P3P );
    $r->err_headers_out->add(
        'Cache-Control' =>
'no-store,no-cache,must-revalidate' );
    $r->err_headers_out->add( 'Pragma' => 'no-cache'
);
    $r->headers_out->set( Location => $url );
    return &Apache::REDIRECT;

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

Re: err_headers_out vs headers_out

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hello again,

On Sat, 18 Oct 2003, Tofu Optimist wrote:

> Hmmm... I had read that thread; none of the postings
> address setting anything beyond a cookie.

Hmmm... in the message to which I pointed, did you also read

  "/me sliently points to recipe 3.13 in the cookbook, too :)"

which addresses exactly your question?

73,
Ged.


Re: err_headers_out vs headers_out

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Tofu Optimist wrote:
> I missed the reference to Recipe 3.13.
> That was right on target.
> Thanks.
> 
> I am interpreting that recipe to mean 
> "when setting the HTTP header fields for a redirect,
> always use err_headers_out, except when setting
> location, which is a special case, and may use
> headers_out".
> 
> Holler if I am off base... otherwise, my gratitude!

sounds right to me :)

--Geoff


Re: err_headers_out vs headers_out

Posted by Tofu Optimist <to...@yahoo.com>.
I missed the reference to Recipe 3.13.
That was right on target.
Thanks.

I am interpreting that recipe to mean 
"when setting the HTTP header fields for a redirect,
always use err_headers_out, except when setting
location, which is a special case, and may use
headers_out".

Holler if I am off base... otherwise, my gratitude!

-TO


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

Re: err_headers_out vs headers_out

Posted by Tofu Optimist <to...@yahoo.com>.
Hmmm... I had read that thread; none of the postings
address setting anything beyond a cookie.
I'm looking for advice on something like this


sub cookie_and_redirect {
    my ( $r, $cookie, $dest ) = @_;

    $r->headers_out->set( Location => $dest );
    $r->headers_out->add( 'P3P' => P3P_CP );
    $r->headers_out->add(
        'Cache-Control' =>
'no-store,no-cache,must-revalidate' );
    $r->headers_out->add( 'Pragma' => 'no-cache' );

    $r->err_headers_out->add( 'Set-Cookie' => $cookie
);
    return &Apache::REDIRECT;
}

or, should it be like this

sub cookie_and_redirect {
    my ( $r, $cookie, $dest ) = @_;

    $r->headers_out->set( Location => $dest );
    $r->err_headers_out->add( 'P3P' => P3P_CP );
    $r->err_headers_out->add(
        'Cache-Control' =>
'no-store,no-cache,must-revalidate' );
    $r->err_headers_out->add( 'Pragma' => 'no-cache'
);

    $r->err_headers_out->add( 'Set-Cookie' => $cookie
);
    return &Apache::REDIRECT;
}

and more importantly, why?  I am interesting in
learning the difference between the two method calls.
As I still don't understand why in all the examples
given the Location param goes in a header_out, while
everything else goes in a err_header_out.


Many thanks

TO



--- Ged Haywood <ge...@www2.jubileegroup.co.uk> wrote:
> Hi there,
> 
> On Sat, 18 Oct 2003, Tofu Optimist wrote:
> 
> > [1] When should one use err_headers_out and when
> > should one use headers_out?
> 
>
http://www.mail-archive.com/modperl@apache.org/msg36041.html
> 
> > [2] Also, what is the difference between the 'set'
> and
> > 'add' methods?  (Where might I find docs for the
> > mod_perl methods?)
> 
> man mod_perl
> 
> 73,
> Ged.
> 
> 
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

Re: err_headers_out vs headers_out

Posted by John Siracusa <si...@mindspring.com>.
On 10/18/03 11:18 AM, Ged Haywood wrote:
> http://www.mail-archive.com/modperl@apache.org/msg36041.html

Whoop, I think this is the post I was looking for earlier :)

http://ken.coar.org/burrow/index?month=2003-07#511

-John


Re: err_headers_out vs headers_out

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,

On Sat, 18 Oct 2003, Tofu Optimist wrote:

> [1] When should one use err_headers_out and when
> should one use headers_out?

http://www.mail-archive.com/modperl@apache.org/msg36041.html

> [2] Also, what is the difference between the 'set' and
> 'add' methods?  (Where might I find docs for the
> mod_perl methods?)

man mod_perl

73,
Ged.