Node.js supertest发布gzip压缩的数据

我想写一个testing发布一些压缩的数据到一个URL如下,但它不工作:

zlib.gzip('foo_bar_data', function (err, buffer) { request(app) .post('/foo/bar') .set('Content-Encoding', 'gzip') .send(buffer) .expect(200) .end(function(err, res){ if (err) return done(err); //various other validations here done(); }); }); 

我认为问题是发送不接受缓冲区。 我仍然希望expect()和end()方法能够正常工作。

 zlib.gzip('foo_bar_data', function (err, buffer) { var ra = request(app) .post('/foo/bar') .set('Content-Encoding', 'gzip'); ra.write(buffer); ra.expect(200); ra.end(function(err, res){ if (err) return done(err); //various other validations here done(); }); });