Skip to content

Commit

Permalink
Handling empty http2 responses
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Nov 24, 2017
1 parent 9d4dd36 commit 885ef5b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/woodland.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ class Woodland {

http2Send (req, res, body, status = 200, headers = null) {
if (res.writable) {
const output = {":status": status};
const output = {":status": status},
empty = status === 204 || status === 304;

each(Object.keys(res._headers).filter(i => invalidHttp2Headers.test(i) === false), i => {
output[i] = res._headers[i];
Expand All @@ -170,9 +171,9 @@ class Woodland {

res.statusCode = status;

if (req.file === void 0) {
if (req.file === void 0 || empty) {
res.respond(output);
res.end(body);
res.end(empty === false ? body : void 0);
} else {
res.respondWithFile(req.file.path, output);
}
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": "4.0.3",
"version": "4.0.4",
"description": "Lightweight HTTP/HTTPS/HTTP2 router with automatic `Allow` & `CORS` headers",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 885ef5b

Please sign in to comment.