Skip to content

Commit

Permalink
When the reply body is JSON.stringified, it also sets the content-typ…
Browse files Browse the repository at this point in the history
…e header to application/json.
  • Loading branch information
Spencer Alger committed Dec 13, 2013
1 parent e6b8832 commit f2f9ed5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/request_overrider.js
Expand Up @@ -191,6 +191,7 @@ function RequestOverrider(req, options, interceptors, remove, cb) {
responseBody = new Buffer(responseBody);
} else {
responseBody = JSON.stringify(responseBody);
response.headers['content-type'] = 'application/json';
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/test_intercept.js
Expand Up @@ -841,6 +841,7 @@ test("reply with JSON", function(t) {

res.setEncoding('utf8');
t.equal(res.statusCode, 200);
t.equal(res.headers['content-type'], 'application/json');
res.on('end', function() {
t.ok(dataCalled);
scope.done();
Expand Down

0 comments on commit f2f9ed5

Please sign in to comment.