I am sending data to the body of an HTTP request to a Restify instance with gzip content encoding. The only problem is that I cannot access the body with the gzipped data in it.
Here is my JS code that I use to define it, but req.body appears as undefined:
server.use(function(req, res, next) {
if(req.headers['content-encoding'] == 'gzip')
{
console.log(req);
var zlib = require("zlib");
var gunzip = zlib.createGunzip();
console.log("Body: "+ req.body)
console.log("Length: " + req.body.length);
}
else
{
apiKey = req.query['apiKey'];
authenticateAndRoute(apiKey, req, res, next)
}
})
Does anyone know how to access req.body here or equivalent?
source
share