Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 681
mscha Avatar asked Feb 08 '23 21:02

mscha


1 Answers

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.

like image 193
mscha Avatar answered May 16 '23 02:05

mscha