I'm attaching some commits that helps me use this library with nginx which won't accept DELETE or PUT's without explicitly defining a Content-Length header in the request. Particularly an issue with DELETE which usually does not contain a body.
See also flatiron/cradle#62 which was for a similar issue in an unrelated library.
Spelling error in main.js
Nginx won't accept a DELETE without a Content-length
Nginx also requires a content-length for PUT requests
Also for POSTS. Changed logic to something simpler to extend.
we also can't go setting all PUT and POST requests to content-length: 0 when they have an entity-body.
That's also not what's happening. Only when the content-length is undefined and the request method is either DELETE, PUT or POST will the content-length be set to 0. When there is a body, content-length has already been set by the time execution reaches my code.
how do you know that there isn't a body? you could be streaming the body to it.
Right, so if that is possible then I might not have understood your code properly. My commits should be squashed anyway. I did some investigation and nginx basically mandates content-length because it does not support chunked bodies. This is not strictly against the HTTP spec but it sure is not required explicitly. Unfortunately it means people with get errors using this library against nginx, but I guess that content-length might get set manually for each relevant request. I will return with another pull request if I come up with something useful.