aacerox / node-rest-client

REST API client from node.js
MIT License
377 stars 132 forks source link

Serializes use wrong header case #144

Closed dploeger closed 7 years ago

dploeger commented 7 years ago

I've just spend some hours debugging code that just ran into nirvana with Node Rest Client.

Turned out, the problem was, that I've specified the header "Content-Type" instead of "content-type". In line line 103 of nrc-serializer-manager, the header is parsed using a lower case form. In my case, the data were serialized to "[Object]", because the JSON serializer didn't kick in. One I changed the header to lower case, all works fine.

This doesn't comply to RFC2616, which documents headers in mixed case, but also states, that the header keys are case insensitive.

I wanted to check back with you, why you've chosen this implementation before submitting a pull request.

ramgom commented 7 years ago

I'm having the exact same problem, for now I will change my header to all lower case.

aacerox commented 7 years ago

fixed in next version 3.0.1

thnx.

dploeger commented 7 years ago

Ah, thank you very much.

ramgom commented 7 years ago

Thanks for your quick response, however I don't think this has been fixed, now you just changed it to use capital letters, I don't think it should be case sensitive:

contentType = request.headers["Content-Type"] && request.headers["Content-Type"].replace(/ /g, '');