diff --git a/src/chunithm.ts b/src/chunithm.ts index 8d2bb57..cf04def 100644 --- a/src/chunithm.ts +++ b/src/chunithm.ts @@ -8,7 +8,20 @@ const app = express(); // attempt to inflate whatever response we send to it whether there's a // Transfer-Encoding header or not. -app.use(compression()); +app.use(function(req, res, next) { + // Chunithm client does not follow the HTTP spec: user agents must indicate + // that they are willing to accept a particular Transfer-Encoding for that + // T-E to be used (unless the T-E in question is "chunked" but w/e), and this + // indication is advisory anyway, the server is permitted to ignore it. + // + // Force this header into the request, since it is not present normally. + + req.headers["accept-encoding"] = "deflate"; + + return next(); +}); + +app.use(compression({ threshold: 0 })); app.use(express.json()); // Trace requests and responses