Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Get the order of HTTP request headers

by furry_marmot (Pilgrim)
on May 05, 2010 at 11:24 UTC ( #838491=note: print w/ replies, xml ) Need Help??


in reply to Get the order of HTTP request headers

> # %ENV is in random order

You do realize that hashes do not keep their order, right? They are designed for random access. If you want data back in the original order, use an array.

my @header = map { [lc($_) , $q->http($_)] } $q->http; print "$_[0] => $_[1]\n" for @header";


Comment on Re: Get the order of HTTP request headers
Download Code
Re^2: Get the order of HTTP request headers
by Anonymous Monk on May 05, 2010 at 11:29 UTC
    Ahem, %ENV is %ENV
    'http' => <<'END_OF_FUNC', sub http { my ($self,$parameter) = self_or_CGI(@_); if ( defined($parameter) ) { $parameter =~ tr/-a-z/_A-Z/; if ( $parameter =~ /^HTTP(?:_|$)/ ) { return $ENV{$parameter}; } return $ENV{"HTTP_$parameter"}; } return grep { /^HTTP(?:_|$)/ } keys %ENV; } END_OF_FUNC
Re^2: Get the order of HTTP request headers
by arc_of_descent (Hermit) on May 05, 2010 at 11:32 UTC

    Yes. My point was that although $q->http returns a list of HTTP header names, they are not in the same order as the request headers were sent.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2014-07-23 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (144 votes), past polls