2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-30 15:24:11 +03:00

Fixing issue for HEAD method and gziped repsonse (#2666)

This commit is contained in:
Nikita Galkin
2020-02-15 12:10:58 +02:00
committed by GitHub
parent 2034c1db7e
commit 12e00b8018
+4 -4
View File
@@ -181,22 +181,22 @@ module.exports = function httpAdapter(config) {
// uncompress the response body transparently if required
var stream = res;
// return the last request in case of redirects
var lastRequest = res.req || req;
switch (res.headers['content-encoding']) {
/*eslint default-case:0*/
case 'gzip':
case 'compress':
case 'deflate':
// add the unzipper to the body stream processing pipeline
stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
stream = (res.statusCode === 204 || lastRequest.method === 'HEAD') ? stream : stream.pipe(zlib.createUnzip());
// remove the content-encoding in order to not confuse downstream operations
delete res.headers['content-encoding'];
break;
}
// return the last request in case of redirects
var lastRequest = res.req || req;
var response = {
status: res.statusCode,
statusText: res.statusMessage,