Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:mikeal/request

  • Loading branch information...
commit 7d10c1e83b4663f592c773e7fece83435585a06f 2 parents 16b5ab9 + aa208cf
@mikeal mikeal authored
Showing with 10 additions and 4 deletions.
  1. +9 −3 index.js
  2. +1 −1  package.json
View
12 index.js
@@ -963,15 +963,21 @@ Request.prototype.multipart = function (multipart) {
return self
}
Request.prototype.json = function (val) {
- this.setHeader('accept', 'application/json')
+ var self = this;
+ var setAcceptHeader = function() {
+ if (!self.headers['accept'] && !self.headers['Accept']) {
+ self.setHeader('accept', 'application/json')
+ }
+ }
+ setAcceptHeader();
this._json = true
if (typeof val === 'boolean') {
if (typeof this.body === 'object') {
- this.setHeader('content-type', 'application/json')
+ setAcceptHeader();
this.body = safeStringify(this.body)
}
} else {
- this.setHeader('content-type', 'application/json')
+ setAcceptHeader();
this.body = safeStringify(val)
}
return this
View
2  package.json
@@ -17,7 +17,7 @@
"url": "http://github.com/mikeal/request/issues"
},
"engines": [
- "node >= 0.3.6"
+ "node >= 0.8.0"
],
"main": "index.js",
"dependencies": {
Please sign in to comment.
Something went wrong with that request. Please try again.