This is my code for embedding koa-compress middleware
app.use(compress({
filter: function (content_type) {
return /text/i.test(content_type)
},
threshold: 1,
flush: require('zlib').Z_SYNC_FLUSH
}))
And following is my response sending code
ctx.body = 'Hello world'
ctx.compress = true
ctx.set('Content-Type', 'text/plain')
ctx.set('content-encoding', 'gzip')
When I hit the URL through CURL I get a simple plain text saying "Hello World" but I believe I should have I got a compressed string because CURL doesn't do decompression by default. And when I hit the same URL on ChromeBrowser, I get the error saying ERR_CONTENT_DECODING_FAILED
When I set content-encoding to gzip, koa-compress should have compressed my response text but it's somehow not doing so. Maybe I'm making some mistake but I don't know what?