Reputation: 164
In my application(node/express), I have to call a third party server to read some data. The response of the third party server will have custom header sessionId
- Id
being capitalized as per the document. But in my application, the custom header key is changed to sessionid
- id
in lowercase. I tested this behaviour in axios and request-promise http client.
Why upper case in header key is converted to lowercase in node/express?
Upvotes: 7
Views: 9691
Reputation: 108776
Express's Request object has a case-insensitive .get('header-name')
method to look up headers. The way the Express team implemented the case-insensitivity is apparently to downcase the header names in when they store them.
Express does case-insensitive matching here to comply with RFC2616's specification that header names are to be case-insensitive. That means your third party server is free to return a header named sessionId
, sessionid
, SeSsIoNiD
or whatever, and it still means sessionid
to your own app. (RFC2616 is the formal specification for the HTTP protocol.)
Upvotes: 12