Skip to content

Commit

Permalink
Fixing pretty bad bug from the composable refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Feb 24, 2012
1 parent eed57af commit 97386b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Request.prototype.start = function () {
response.body = buffer.join('')
}

if (self.json) {
if (self._json) {
try {
response.body = JSON.parse(response.body)
} catch (e) {}
Expand Down Expand Up @@ -554,6 +554,7 @@ Request.prototype.multipart = function (multipart) {
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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/test-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ s.listen(s.port, function () {
});

// test .del(string, function)
request.defaults({headers:{foo:"bar"}}).del(s.url + '/del', function (e, r, b){
request.defaults({headers:{foo:"bar"}, json:true}).del(s.url + '/del', function (e, r, b){
if (e) throw e;
assert.deepEqual('bar', b.foo);
counter += 1;
Expand Down

0 comments on commit 97386b5

Please sign in to comment.