2
0
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:
Nick Uraltsev
2016-05-18 19:56:20 -07:00
2 changed files with 17 additions and 0 deletions
+5
View File
@@ -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') {
+12
View File
@@ -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('ж');