0

I'm writing a superagent client for a PHP application.

I'm struggling to get one of the first examples to work:

.set('X-API-Key', 'foobar')

appears to send headers x-api-key: foobar (and user-agent: node-superagent/1.7.2) to server, so I lose the case. Is it normal (i.e. I should make serverside case-insensitive when working with superagent), or am I missing something?

A quick dive into superagent source code shows that there is intentional .toLowerCase call, but it just doesn't seem right, does it?

tishma
  • 1,855
  • 1
  • 21
  • 43
  • Although headers are meant to be case-insensitive, it's interesting that same code on Mac is sending lowercase headers, but on Windows they are unchanged. (both using superagent 1.7.2) – tishma Feb 24 '16 at 09:00

1 Answers1

0

OH boy!

I totally missed this: Are HTTP headers case-sensitive?

The answer is - http headers should not be case sensitive, so sending lowercase is valid, and server-side must take care of it.

It is however easy to fall to getallheaders() which returns an assoc array which is case sensitive.

Community
  • 1
  • 1
tishma
  • 1,855
  • 1
  • 21
  • 43