Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

How to read request headers?

by expresspotato (Beadle)
on Jul 19, 2008 at 22:28 UTC ( #698859=perlquestion: print w/ replies, xml ) Need Help??
expresspotato has asked for the wisdom of the Perl Monks concerning the following question:

Hello, So I have a script that outputs the file they have requested, its faily simple. But now, many browsers like requesting things in small ranges of bytes often to incorporate some sort of buffering scheme. Now I have to be able to read the HTTP request headers to find what range they're requesting and only return that range. How can I read the HTTP request headers sent along from their browser? Thank you!!!

Comment on How to read request headers?
Re: How to read request headers?
by grep (Monsignor) on Jul 19, 2008 at 23:34 UTC
    It would be much easier if you posted some code (preferably a small test case). I have no idea if you are using CGI, CGI::Lite, or any other CGI modules.

    That being said one way to see the Content-Range header would be to use %ENV to pull the 'HTTP_CONTENT_RANGE'.

    print $ENV{HTTP_CONTENT_RANGE};

    Here is a test CGI script:

    use warnings; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; my $q = CGI->new; print $q->header,$q->start_html; print '<pre>'; print Dumper \%ENV; print '</pre>'; print "<br>Content-Range: ",$ENV{HTTP_CONTENT_RANGE};

    And a small fake request:

    use warnings; use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => 'http://www.cicisdw.com/foo.cgi'); $req->header( 'Content-Range' => 'bytes 0-499/500' ); my $resp = $ua->request($req); print $resp->{_content};
    grep
    One dead unjugged rabbit fish later...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://698859]
Approved by jettero
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2014-07-30 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (235 votes), past polls