Skip to content

Commit

Permalink
Optimizing res.write() shim for http2
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jul 9, 2018
1 parent 9d24027 commit ca6341b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/woodland.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ class Woodland extends Base {
res.getHeaders = () => clone(res._headers);

res.write = (...args) => {
let options = args[1];
if (res.headersSent === false) {
let options = args[1];

if (options === void 0) {
options = {":status": res.statusCode};
if (options === void 0) {
options = {":status": res.statusCode};

each(Object.keys(res._headers), i => {
options[i] = res._headers[i];
});
}
each(Object.keys(res._headers), i => {
options[i] = res._headers[i];
});
}

if (res.headersSent === false) {
res.respond(options);
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woodland",
"version": "7.1.11",
"version": "7.1.12",
"description": "Lightweight HTTP/HTTP2 router with automatic `Allow` & `CORS` headers",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ca6341b

Please sign in to comment.