2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Fixing Z_BUF_ERROR when no content (#4701)

* Fix Z_BUF_ERROR when no content

* Refactored code

* Fix undefined check

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Jamie Telin
2022-05-12 07:27:39 +02:00
committed by GitHub
parent 807918bda2
commit c6ec5fc867
+7 -2
View File
@@ -236,9 +236,14 @@ module.exports = function httpAdapter(config) {
// return the last request in case of redirects
var lastRequest = res.req || req;
// if decompress disabled we should not decompress
if (config.decompress !== false) {
// if no content, but headers still say that it is encoded,
// remove the header not confuse downstream operations
if (data && data.length === 0 && res.headers['content-encoding']) {
delete res.headers['content-encoding'];
}
// if no content, is HEAD request or decompress disabled we should not decompress
if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
switch (res.headers['content-encoding']) {
/*eslint default-case:0*/
case 'gzip':