All,

I am working on Recipe 3.4. I have the following saved as cgi-perl/try.pl:

#! /usr/bin/perl -w
# file: try.pl

use strict;
use Apache::Const qw(:common);

my $r=shift;

# Grab all of the headers at once
my %headers_in=$r->headers_in;

# or get a specific header and do something with it
my $gzip=$r->headers_in->get('Accept-Encoding')=~m/gzip/;

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

print "The host in your URL is: ", $headers_in{'Host'}, "\n";
print "Your browser is: ", $headers_in{'User-Agent'}, "\n";
print "Your browser accepts gzip encoded data\n" if $gzip;

return OK;

When I access it (using Lynx) via localhost/cgi-perl/try.pl, the response I
get is:

The host in your URL is:
Your browser is:
Your browser accepts gzip encoded data

Can someone explain why the Host and User-Agent are missing?

Secondly, if I save it as cgi-perl/try.pl like this:

#! /usr/bin/perl -w
# file: try.pl

use strict;
use Apache::Const qw(:common);

sub handler {

    my $r=shift;

    # Grab all of the headers at once
    my %headers_in=$r->headers_in;

    # or get a specific header and do something with it
    my $gzip=$r->headers_in->get('Accept-Encoding')=~m/gzip/;

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

    print "The host in your URL is: ", $headers_in{'Host'}, "\n";
    print "Your browser is: ", $headers_in{'User-Agent'}, "\n";
    print "Your browser accepts gzip encoded data\n" if $gzip;

    return OK;

}

Then when I access it in lynx, I get a blank screen. Also, I am used to
doing something in httpd.conf when using these handlers. What do I have to
do in this second case to get a result?



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to