Skip to content

Commit

Permalink
Improvements to json handling and defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Aug 13, 2011
1 parent 59eab0e commit 76bf5f6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ Request.prototype.request = function () {

if (options.json) {
options.headers['content-type'] = 'application/json'
options.body = JSON.stringify(options.json)
if (typeof options.json === 'boolean') {
options.body = JSON.stringify(options.body)
} else {
options.body = JSON.stringify(options.json)
}

} else if (options.multipart) {
options.body = ''
options.headers['content-type'] = 'multipart/related;boundary="frontier"'
Expand Down Expand Up @@ -392,6 +397,7 @@ module.exports = request
request.defaults = function (options) {
var def = function (method) {
var d = function (opts, callback) {
if (typeof opts === 'string') opts = {uri:opts}
for (i in options) {
if (opts[i] === undefined) opts[i] = options[i]
}
Expand Down

0 comments on commit 76bf5f6

Please sign in to comment.