Re: Adding / Modifing Response Headers on mp2

2003-04-03 Thread Nick Tonkin
On Thu, 3 Apr 2003, Denis Banovic wrote:

> Hi!
>
> I'm trying to figure out, how to Add / Modify the HTTP Headers like
> Content Type, Cache aso...
>
> on mod_perl 1 I've used:
>
> $r->send_cgi_header($custom_headers);
>
> but this won't work mod_perl 2...
>
> I've searched in Apache::compat all I've found was the function header_out
> that internally calls $r->headers_out()...
>
> Can somebody please tell me how to set the right headers???

TFM is a little hard to find, but when you R http://xrl.us/fix you'll see that
all you need to do to call $r->send_cgi_header() is:

use Apache::Response();

The docs need work, but if you are porting your code from mp1 to mp2 you
really should spend some time reading _all_ the mp2 docs, don't you think?

Start at http://perl.apache.org/docs/2.0/devel/porting/porting.html and just
follow every link from there.

> here is the code from Apache::compat

Most of us already have that :)



- nick

-- 


Nick Tonkin   {|8^)>



Adding / Modifing Response Headers on mp2

2003-04-02 Thread Denis Banovic
Hi!

I'm trying to figure out, how to Add / Modify the HTTP Headers like
Content Type, Cache aso...

on mod_perl 1 I've used:
 
$r->send_cgi_header($custom_headers);

but this won't work mod_perl 2...

I've searched in Apache::compat all I've found was the function header_out
that internally calls $r->headers_out()... 

Can somebody please tell me how to set the right headers???

Thanks a lot!


here is the code from Apache::compat


sub table_get_set {
my($r, $table) = (shift, shift);
my($key, $value) = @_;

if (1 == @_) {
return wantarray() 
?   ($table->get($key))
: scalar($table->get($key));
}
elsif (2 == @_) {
if (defined $value) {
return wantarray() 
?($table->set($key, $value))
:  scalar($table->set($key, $value));
}
else {
return wantarray() 
?   ($table->unset($key))
: scalar($table->unset($key));
}
}
elsif (0 == @_) {
return $table;
}
else {
my $name = (caller(1))[3];
warn "Usage: \$r->$name([key [,val]])";
}
}

sub header_out {
my $r = shift;
return wantarray() 
?   ($r->table_get_set(scalar($r->headers_out), @_))
: scalar($r->table_get_set(scalar($r->headers_out), @_));
}