Skip to content

Commit

Permalink
Merge pull request #1401 from MamfTheKramf/http-response-chaining
Browse files Browse the repository at this point in the history
fix: enable method chaining for after writeHead
  • Loading branch information
lamweili committed Apr 5, 2024
2 parents 4027fc7 + 24a6e36 commit bc59c87
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/connect-logger.js
Expand Up @@ -273,6 +273,7 @@ module.exports = function getLogger(logger4js, options) {

res.__statusCode = code;
res.__headers = headers || {};
return res;
};

// hook on end request to emit the log entry of the HTTP request.
Expand Down
1 change: 1 addition & 0 deletions test/tap/connect-context-test.js
Expand Up @@ -58,6 +58,7 @@ class MockResponse extends EE {

writeHead(code /* , headers */) {
this.statusCode = code;
return this;
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/tap/connect-logger-test.js
Expand Up @@ -58,6 +58,7 @@ class MockResponse extends EE {

writeHead(code /* , headers */) {
this.statusCode = code;
return this;
}
}

Expand Down Expand Up @@ -87,8 +88,7 @@ function request(
next = () => {};
}
cl(req, res, next);
res.writeHead(code, resHeaders);
res.end('chunk', 'encoding');
res.writeHead(code, resHeaders).end('chunk', 'encoding');
}

test('log4js connect logger', (batch) => {
Expand Down
1 change: 1 addition & 0 deletions test/tap/connect-nolog-test.js
Expand Up @@ -49,6 +49,7 @@ class MockResponse extends EE {

writeHead(code /* , headers */) {
this.statusCode = code;
return this;
}
}

Expand Down

0 comments on commit bc59c87

Please sign in to comment.