Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #236 DELETE should set Content-Length to 0 #711

Closed
wants to merge 3 commits into from

Conversation

soyuka
Copy link

@soyuka soyuka commented Jul 29, 2015

No description provided.

@@ -0,0 +1,21 @@
var EventEmitter = require('events').EventEmitter
, request = require('../../')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please follow existing style for source files/vars

request.del('http://localhost:3005/nonexistant')
.end(function(err, res) {
assert(err)
res.request.req._headers['content-length'].should.equal(0)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a better way to check the header that has been sent?

@defunctzombie
Copy link
Contributor

@soyuka the client aka browser version of this library

@soyuka
Copy link
Author

soyuka commented Jul 30, 2015

@defunctzombie nope, the browser should set the Content-Length header automatically. XMLHttpRequest isn't allowed to set it anyway.

Could you check out my last comment : #711 (comment) ? Thanks.

@soyuka
Copy link
Author

soyuka commented Aug 7, 2015

Bump

@kornelski kornelski changed the title Fix #236 DELETE should set content-type to 0 Fix #236 DELETE should set Content-Length to 0 Nov 27, 2015
@kornelski
Copy link
Contributor

As far as I know HTTP RFC does not forbid DELETE requests to have a body (even GET requests can have one!), so forcing 0-length body wouldn't be appropriate.

Sorry @soyuka. That's a well-written pull request, but I think it's not a behavior the library should have.

@kornelski kornelski closed this Nov 27, 2015
@soyuka
Copy link
Author

soyuka commented Nov 27, 2015

@pornel maybe that was the cause:

A server MUST generate a Content-Length field with a value of "0" if no payload body is to be sent in the response.

https://tools.ietf.org/html/rfc7231

Thanks for the answer. Anyway, I'm almost always extending supertest/superagent for my needs. I can provide an example if someone wants.

You may want to close #236 too.

@kornelski
Copy link
Contributor

That clause is for OPTIONS (in that case I wouldn't be opposed to setting content-length if nodejs doesn't do that already).

For DELETE I see:

A payload within a DELETE request message has no defined semantics;
sending a payload body on a DELETE request might cause some existing
implementations to reject the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants