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();
});
});
Node.js supertest post gzipped data
-
04-06-2022 - |
Pregunta
I'd like to write a test to post up some zipped data to a url as follows, but it doesn't work:
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. I'd still like to have the expect() and end() methods work though.
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow