Permalink
Browse files

It probably shouldln't set content type if there's no body.

  • Loading branch information...
1 parent e82dd8a commit 1421be7f889ea2b26535e934e88e96e1da8f437c @HenrikJoreteg committed Oct 4, 2012
Showing with 2 additions and 2 deletions.
  1. +1 −1 main.js
  2. +1 −1 tests/test-defaults.js
View
2 main.js
@@ -789,14 +789,14 @@ Request.prototype.multipart = function (multipart) {
return self
}
Request.prototype.json = function (val) {
- this.setHeader('content-type', 'application/json')
this.setHeader('accept', 'application/json')
this._json = true
if (typeof val === 'boolean') {
if (typeof this.body === 'object') this.body = JSON.stringify(this.body)
} else {
this.body = JSON.stringify(val)
}
+ if (this.body) this.setHeader('content-type', 'application/json')
return this
}
Request.prototype.aws = function (opts, now) {
View
2 tests/test-defaults.js
@@ -23,7 +23,7 @@ s.listen(s.port, function () {
s.on('/post', function (req, resp) {
assert.equal(req.headers.foo, 'bar');
- assert.equal(req.headers['content-type'], 'application/json');
+ assert.equal(req.headers['accept'], 'application/json');
assert.equal(req.method, 'POST')
resp.writeHead(200, {'Content-Type': 'application/json'});
resp.end(JSON.stringify({foo:'bar'}));

0 comments on commit 1421be7

Please sign in to comment.