<h3 dir="auto">Describe the bug</h3>
<p dir="auto"><code class="notranslate">content-encoding</code> header is ignored if <code class="notranslate">content-length</code> is not set on response. For connect compression middleware, the returned response appears to have <code class="notranslate">Transfer-Encoding</code>, <code class="notranslate">content-encoding</code>, but no <code class="notranslate">content-length</code> header, so axios request returns uncompressed value.</p>
<p dir="auto">I believe <code class="notranslate">content-length</code> is an optional header?</p>
<p dir="auto">Related to commit: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/axios/axios/commit/a3d901777bc06e78adae3081f694cdbf76241303/hovercard" href="https://github.com/axios/axios/commit/a3d901777bc06e78adae3081f694cdbf76241303"><tt>a3d9017</tt></a></p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Code snippet</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const responseLength = +res.headers['content-length'];
...
// if no content, but headers still say that it is encoded,
// remove the header not confuse downstream operations
if ((!responseLength || res.statusCode === 204) &amp;&amp; res.headers['content-encoding']) {
  delete res.headers['content-encoding'];
}"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">responseLength</span> <span class="pl-c1">=</span> <span class="pl-c1">+</span><span class="pl-s1">res</span><span class="pl-kos">.</span><span class="pl-c1">headers</span><span class="pl-kos">[</span><span class="pl-s">'content-length'</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
...
<span class="pl-c">// if no content, but headers still say that it is encoded,</span>
<span class="pl-c">// remove the header not confuse downstream operations</span>
<span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-s1">responseLength</span> <span class="pl-c1">||</span> <span class="pl-s1">res</span><span class="pl-kos">.</span><span class="pl-c1">statusCode</span> <span class="pl-c1">===</span> <span class="pl-c1">204</span><span class="pl-kos">)</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">res</span><span class="pl-kos">.</span><span class="pl-c1">headers</span><span class="pl-kos">[</span><span class="pl-s">'content-encoding'</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">delete</span> <span class="pl-s1">res</span><span class="pl-kos">.</span><span class="pl-c1">headers</span><span class="pl-kos">[</span><span class="pl-s">'content-encoding'</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">This was working in 1.2.x</p>
<h3 dir="auto">Axios Version</h3>
<p dir="auto">1.2.0</p>
<h3 dir="auto">Adapter Version</h3>
<p dir="auto">HTTP</p>
<h3 dir="auto">Browser</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Browser Version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Node.js Version</h3>
<p dir="auto">16</p>
<h3 dir="auto">OS</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional Library Versions</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional context/Screenshots</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Describe the bug</h3>
<p dir="auto">`<br>
var axios = require('axios');<br>
var data = JSON.stringify({<br>
"production_status": "",<br>
"package_status": [],<br>
"extra_status_reason": [],<br>
"page": 1,<br>
"limit": 1<br>
});</p>
<p dir="auto">var config = {<br>
method: 'post',<br>
url: '<a href="https://example.com/" rel="nofollow">https://example.com/</a>',<br>
headers: {<br>
'Authorization': 'Bearer token',<br>
},<br>
data: {<br>
"production_status": "",<br>
"package_status": [],<br>
"extra_status_reason": [],<br>
"page": 1,<br>
"limit": 1<br>
}<br>
};</p>
<p dir="auto">axios(config)<br>
.then(function (response) {<br>
console.log(response.data);<br>
})<br>
.catch(function (error) {<br>
console.log(error);<br>
});<br>
`</p>
<p dir="auto">When i send API this response<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/73536823/203527806-e7f74bca-c6aa-45b0-b9b5-73138981228b.png"><img src="https://user-images.githubusercontent.com/73536823/203527806-e7f74bca-c6aa-45b0-b9b5-73138981228b.png" alt="image" style="max-width: 100%;"></a><br>
I want respose must be json like that<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/73536823/203528048-a5555c94-ce21-4f7a-922b-53337e49aca6.png"><img src="https://user-images.githubusercontent.com/73536823/203528048-a5555c94-ce21-4f7a-922b-53337e49aca6.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Code snippet</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Axios Version</h3>
<p dir="auto">1.2.0</p>
<h3 dir="auto">Adapter Version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Browser</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Browser Version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Node.js Version</h3>
<p dir="auto">14.20.1</p>
<h3 dir="auto">OS</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional Library Versions</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional context/Screenshots</h3>
<p dir="auto"><em>No response</em></p>