![](/img/trans.png)
[英]Trying to post multipart/form-data with node.js supertest
[英]Node.js supertest post gzipped data
我想編寫一個測試,將一些壓縮數據發布到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();
});
});
我認為問題是send不接受緩沖區。 我仍然希望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.