Ged Haywood wrote:
Hi there,

On Sat, 15 Nov 2003, [iso-8859-1] "SUCH SANMART?N, GERARD" wrote:


i'm trying to substitute my old cgi %ENV with $r->headers_in ...

my %temp = $apache->headers_in;


Isn't $apache->headers_in a hashref?

Yes. It returns an APR::Table object, which is a also a tied hash reference. So you can use either the hash or the object API. (exactly the same as in mp1, though there the class was Apache::Table)
http://perl.apache.org/docs/2.0/api/APR/Table.html
There are many other methods which return APR::Table objects.


Next time you encounter a problem, search the docs:
http://perl.apache.org/search/swish.cgi?query=headers_in&sbm=SecI&submit=search

Granted
http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html
needs to have this info, but we didn't get around doing it yet.

> my %temp = $apache->headers_in;
> foreach (keys %temp) {
>         print $temp{$_};
>         }

this should be:

my $temp = $apache->headers_in;
foreach (keys %$temp) {
        print "$_ $temp->{$_}\n";
}

you probably want to see the keys as well.

> # now what i'm used to do
> $apache -> subprocess_env->clear;

you don't need to clear.

> $apache -> subprocess_env;

Yup, that populates %ENV, with things like $ENV{REMOTE_HOST}, familiar from mod_cgi.

> In other part of the code i tried the next:
> $info->{host} =         $apache->headers_in->get('REMOTE_HOST');
> $info->{cookie} =       $apache->headers_in->get('HTTP_COOKIE');

look at the dump of %$temp and you will see what headers the client gives to you. There is no header REMOTE_HOST, so of course you don't get it. Instead you should use $apache->get_remote_host(). And it's not HTTP_COOKIE but $apache->headers_in->get('Cookie'). Again look at the dump.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to