<?xml version="1.0" encoding="windows-1252"?>
<node id="838453" title="Get the order of HTTP request headers" created="2010-05-05 02:52:34" updated="2010-05-05 02:52:34">
<type id="115">
perlquestion</type>
<author id="147902">
arc_of_descent</author>
<data>
<field name="doctext">
&lt;p&gt;
Greetings to All,

&lt;p&gt;
I asked this question in the chatterbox a couple of weeks back, but looks like this task is tougher than I thought. Hence I'm posting it here in the hopes it reaches a wider audience and of course, a solution.

&lt;p&gt;
I need to get the exact order in which the HTTP request headers were sent by the browser from within my CGI script. I need this to perform browser fingerprinting.

&lt;p&gt;
All the following don't seem to work

&lt;code&gt;

# %header will be in random order
my $q = CGI-&gt;new;
my %header = map { lc($_) =&gt; $q-&gt;http($_) } $q-&gt;http;

# %ENV is in random order
print Dumper \%ENV

my $h = HTTP::Headers-&gt;new(%ENV);

# this returns the headers in the recommended 
# "Good Practice" order. 
print Dumper $h-&gt;header_field_names;

# this doesn't work as well
print $h-&gt;as_string;

&lt;/code&gt;

&lt;p&gt;
You can check the order in which the request headers were sent using Firebug. 

&lt;p&gt;
PHP's getfullheaders() works :(

&lt;p&gt;
Any help would be great. Perhaps some Apache module can help? I will be releasing code to this fingerprinting module to CPAN.

&lt;p&gt;
Thanks!


</field>
</data>
</node>
