4

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?

mscha
  • 6,509
  • 3
  • 24
  • 40

1 Answers1

8

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.

mscha
  • 6,509
  • 3
  • 24
  • 40
  • HTTP headers are case irrelevant so if the application really requires a lower case header it might get in trouble with proxies normalizing the headers. – Steffen Ullrich Oct 02 '15 at 04:32
  • @SteffenUllrich although it sort of makes sense that if an uppercase line is `-`, then a lowercase line would be `_` and thus with case-insensitive stuff it should not matter which one is used, that is probably not the case here. :D OP said it gets changed to `M-Id` with a dash, but they require an underscore. – simbabque Oct 02 '15 at 08:23
  • @Steffen I couldn't resist the joke with the dash and the underscore, sorry about that. It's Friday after all. :) – simbabque Oct 02 '15 at 09:00