Forum Moderators: coopster & phranque

Message Too Old, No Replies

how to access the http header in CGI program?

access the fields like Range field.

         

tigrised

8:13 am on Apr 11, 2007 (gmt 0)

10+ Year Member



I am going to write a cgi program which support the multithread download application such as flashget.

the cgi program is written using CGI.pm, but i don't know how the access the http header fields,such as "Range:".

if the CGI.pm doesn't support this,how i get this message in my program?

anybody can help me? thanks in advance.

the http header is like the following:

Wed Apr 11 15:33:03 2007 GET /cgi-bin/upgrade.cgi?a=2 HTTP/1.1
Wed Apr 11 15:33:03 2007 Host: 10.200.11.58
Wed Apr 11 15:33:03 2007 Accept: */*
Wed Apr 11 15:33:03 2007 Referer: [10.200.11.58...]
Wed Apr 11 15:33:03 2007 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)
Wed Apr 11 15:33:03 2007 Range: bytes=26214400-
Wed Apr 11 15:33:03 2007 Pragma: no-cache
Wed Apr 11 15:33:03 2007 Cache-Control: no-cache
Wed Apr 11 15:33:03 2007 Connection: close

Dabrowski

10:50 am on Apr 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can do it, can't remember how. Look at the CGI manpage at [search.cpan.org...]

phranque

12:48 pm on Apr 11, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you can do it like this (case-insensitive header names):
$range = http('Range');

tigrised

1:30 am on Apr 12, 2007 (gmt 0)

10+ Year Member



thank you very much. i got it now.

perl_diver

8:07 pm on Apr 12, 2007 (gmt 0)

10+ Year Member



the http() function just reads the ENV hash, so doing this should work also:

my $range = $ENV{'Range'};

but using the http() function/method is OK.