mirror of
https://github.com/tenrok/axios.git
synced 2026-05-27 14:47:43 +03:00
Merge pull request #327 from mzabriskie/pr/303
Fixing handling of compression errors
This commit is contained in:
@@ -116,6 +116,11 @@ module.exports = function httpAdapter(resolve, reject, config) {
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('error', function handleStreamError(err) {
|
||||
if (aborted) return;
|
||||
reject(err);
|
||||
});
|
||||
|
||||
stream.on('end', function handleStreamEnd() {
|
||||
var responseData = Buffer.concat(responseBuffer);
|
||||
if (config.responseType !== 'arraybuffer') {
|
||||
|
||||
@@ -102,6 +102,18 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
testGunzipErrorHandling: function (test) {
|
||||
server = http.createServer(function (req, res) {
|
||||
res.setHeader('Content-Type', 'application/json;charset=utf-8');
|
||||
res.setHeader('Content-Encoding', 'gzip');
|
||||
res.end('invalid response');
|
||||
}).listen(4444, function () {
|
||||
axios.get('http://localhost:4444/').catch(function (error) {
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
testUTF8: function (test) {
|
||||
var str = Array(100000).join('ж');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user