koajs/compress

koa-compress not compressing response body.

varad11 opened this issue · 1 comments

I am using koa-compress module to compress responses.

Following ways I have tried to use it.

import compress from "koa-compress";
import { constants } from "zlib";

Method 1).
app.use(compress());

Method 2).
app.use(compress({
filter: function (content_type) { return ( /json/i.test(content_type) || /text/i.test(content_type)) },
threshold: 1024,
gzip: {
flush: constants.Z_NO_FLUSH,
level: constants.Z_BEST_COMPRESSION
}
}));

The response json object I receive is not compressed.

I have tried adding "Accept-Encoding" in both ways application/gzip & gzip.
But no success.

Following versions I am currently using.

"@types/koa-compress": "^4.0.0",
"koa-compress": "^4.0.1",

Was testing on postman, which failed to give right size of compressed data. Above samples working effectively.
Thanks.