Open
Description
We want to send compressed body by gzip HTTP request in chai-http in mocha.
let chai = require('chai');
let chaiHttp = require('chai-http');
const zlib = require('zlib');
chai.use(chaiHttp);
object = {
"content": {
"data": {
"key": "testval"
}
}
};
const objStr = JSON.stringify(object);
const objBuf = Buffer.from(objStr, "utf-8");
const bodyContent = zlib.gzipSync(objBuf);
const bodyLen = Buffer.byteLength(bodyContent, 'utf-8');
chai.request("http://serverurl")
.post('/path')
.set('Content-Type', 'application/json')
.set('Content-Encoding', 'gzip')
.set('Content-Length', bodyLen)
.set('Accept-Encoding', 'gzip')
.send(bodyContent)
.end((err, res) => {
expect(err).to.be.null;
expect(res).to.have.status(200);
done();
});
However, we met the error Error: incorrect header check at Zlib.zlibOnError on the server-side
. Is there anything am I missing?
Metadata
Assignees
Labels
No labels