Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Get the order of HTTP request headers

by ig (Vicar)
on May 05, 2010 at 09:32 UTC ( #838472=note: print w/ replies, xml ) Need Help??


in reply to Get the order of HTTP request headers

If you're using mod_perl registy scripts, something like the following might give you what you want:

#!/usr/bin/perl # use strict; use warnings; use Apache2::RequestUtil; use Apache2::RequestRec; $| = 1; print "Content-type: text/plain\n\n"; my $r = Apache2::RequestUtil->request; print $r->as_string();

On my system, this produces:

GET /test.pl HTTP/1.1 Host: directory.localhost User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/ +20100401 Ubuntu/9.10 (karmic) Firefox/3.5.9 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0. +8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cache-Control: max-age=0 HTTP/1.1 (null)


Comment on Re: Get the order of HTTP request headers
Select or Download Code
Re^2: Get the order of HTTP request headers
by arc_of_descent (Hermit) on May 05, 2010 at 11:28 UTC

    Thank you! I've got it working under mod_perl.

    Now if only there is some way to get the Apache2::* modules working under a vanilla CGI script.

      Impossible, CGI passes http headers via %ENV

      There are pure Perl HTTP servers available. If you don't need the performance of of mod_perl, maybe one of these would suffice. This would give you direct access to the request.

      Is there any reason not to use mod_perl?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (14)
As of 2014-10-23 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (126 votes), past polls