Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc59c87

Browse files
authored
Merge pull request #1401 from MamfTheKramf/http-response-chaining
fix: enable method chaining for after writeHead
2 parents 4027fc7 + 24a6e36 commit bc59c87

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

lib/connect-logger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ module.exports = function getLogger(logger4js, options) {
273273

274274
res.__statusCode = code;
275275
res.__headers = headers || {};
276+
return res;
276277
};
277278

278279
// hook on end request to emit the log entry of the HTTP request.

test/tap/connect-context-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class MockResponse extends EE {
5858

5959
writeHead(code /* , headers */) {
6060
this.statusCode = code;
61+
return this;
6162
}
6263
}
6364

test/tap/connect-logger-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class MockResponse extends EE {
5858

5959
writeHead(code /* , headers */) {
6060
this.statusCode = code;
61+
return this;
6162
}
6263
}
6364

@@ -87,8 +88,7 @@ function request(
8788
next = () => {};
8889
}
8990
cl(req, res, next);
90-
res.writeHead(code, resHeaders);
91-
res.end('chunk', 'encoding');
91+
res.writeHead(code, resHeaders).end('chunk', 'encoding');
9292
}
9393

9494
test('log4js connect logger', (batch) => {

test/tap/connect-nolog-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class MockResponse extends EE {
4949

5050
writeHead(code /* , headers */) {
5151
this.statusCode = code;
52+
return this;
5253
}
5354
}
5455

0 commit comments

Comments
 (0)