kappa has asked for the wisdom of the Perl Monks concerning the following question:

Good day, fellow monks!

Is there a way to get the order of HTTP headers the client sent to us using mod_perl? It looks like HTTP headers always get to Perl level represented as hash.

--kap

Replies are listed 'Best First'.
Re: Order of HTTP request headers
by Fletch (Bishop) on Oct 14, 2008 at 15:42 UTC

    One wonders, erm, why? The order is neither specified nor significant (apart from a general recommended ordering of header types), so why do you think it's of any use?

    (Having said that, $r->headers_in returns an APR::Table instance rather than a true hash, and that class supports a method $tbl->do( $callback ) which iterates over the items in the table passing key/value paris to the callback (presumably in order as the APR::Table docs specifies keys are stored in the order added). That might get what you're looking for.)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      We're trying to use the order of HTTP request headers as a factor in our antifraud system. We found out that our beloved bots send the headers in a distinctly different order than all current browsers.

      Thanks for the advice! Too bad our main system uses Apache 1.3 but we'll probably use the APR::Table in another place.

      --kap