Skip to content

Commit

Permalink
Fix ladjs#236 DELETE should set content-type to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Jul 29, 2015
1 parent 1cd3653 commit d116e91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ Request.prototype.request = function(){
// request
var req = this.req = mod.request(options);
if ('HEAD' != options.method) req.setHeader('Accept-Encoding', 'gzip, deflate');
if('DELETE' == options.method) req.setHeader('Content-Type', 0);
this.protocol = url.protocol;
this.host = url.host;

Expand Down
21 changes: 21 additions & 0 deletions test/node/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var EventEmitter = require('events').EventEmitter
, request = require('../../')
, express = require('express')
, assert = require('assert')
, app = express();

app.delete('/delete-me', function(req, res){
return res.status(200).end();
});

app.listen(3005);

describe('delete with length', function(){
it('should delete with a content-length of 0', function(done){
request.del('http://localhost:3005/delete-me')
.end(function(err, res) {
res.headers['Content-Type'].should.equal('0');
return done()
})
})
})

0 comments on commit d116e91

Please sign in to comment.