ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.58k stars 1.33k forks source link

Request hang when statusCode=204 and content-encoding = gzip #1597

Open samuraitruong opened 3 years ago

samuraitruong commented 3 years ago

In my test, I have below request

Response 204- no content but in the header I have content-encoding: gzip transfer-encoding: chunked

I know that is the invalid header for 204 but this is not in my control,

In this case, my code keeps hanging forever without any error

My proposal is if the response is 204 and the incoming stream is empty, we can ignore the gzip

Note: I tested the same request with the postman and got a successful response with an empty body

Working: image

Not working: image

After many test, I can confirm when transfer-encoding: chunked and status=204 it will cause this issue.