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?
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.