Certain servers requires a content-length for DELETE and PUT requests #41

Closed
wants to merge 4 commits into from

2 participants

@tedeh

Hello,

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.

@mikeal
request member

we also can't go setting all PUT and POST requests to content-length: 0 when they have an entity-body.

@tedeh

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.

@mikeal
request member

how do you know that there isn't a body? you could be streaming the body to it.

@mikeal mikeal closed this Jul 21, 2011
@tedeh

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment