[英]Node.js supertest post gzipped data
I'd like to write a test to post up some zipped data to a url as follows, but it doesn't work: 我想编写一个测试,将一些压缩数据发布到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();
});
});
I think the problem is that send doesn't accept a buffer. 我认为问题是send不接受缓冲区。 I'd still like to have the expect() and end() methods work though.
我仍然希望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();
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.