Search code examples
perlwww-mechanize

Using WWW::Mechanize, how do I add a lower case header with an underscore?


I'm using an API that requires me to use a header named "m_id" to the request.

When I use

$mech->add_header('m_id' => 'whatever')

WWW::Mechanize (or rather HTTP::Headers) “helpfully” changes the header name to “M-Id”. Which doesn't work.

Is there any way to prevent this from happening?


Solution

  • I thought I RTFMed before posting, but not well enough... A second read through the HTTP::Headers perldoc told me to use:

    $mech->add_header(':m_id'=>'whatever');
    

    and that does the trick.