Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ Response.prototype.__send = function __send() {

// Set sane defaults for optional arguments if they were not provided and
// we failed to derive their values
code = code || 200;
code = code || self.statusCode || 200;
headers = headers || {};

// Populate our response object with the derived arguments
Expand Down
12 changes: 12 additions & 0 deletions test/response.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,15 @@ test('GH-951: sendRaw accepts only strings or buffers', function (t) {
// throw away response, we don't need it.
STRING_CLIENT.get(join(LOCALHOST, '/16'));
});

test('GH-1429: setting code with res.status not respected', function (t) {
SERVER.get('/404', function (req, res, next) {
res.status(404);
res.send(null);
});

CLIENT.get(join(LOCALHOST, '/404'), function (err, _, res) {
t.equal(res.statusCode, 404);
t.end();
});
});