Closed quinw68 closed 3 years ago
FYI, a temporary workaround to allow the browser to handle the content-length on its own is to just remove the content-length header after receiving the response:
readableStream.on('response', () => { res.removeHeader('content-length'); })
What happens if you set options.decompress
to false
?
@szmarczak That actually works and makes sense as to why the header had the wrong size. I guess this is a non-issue. Thanks for the tip sir
Describe the bug
When piping a got http GET readable stream to an express "response" writable stream, the content-length header is automatically getting set incorrectly for small files that only have one chunk to receive in the stream. It seems to be using the value from the "downloadProgress" event instead of how many bytes were actually read.
Actual behavior
The content-length header that is set by the got stream is not set to the actual number of bytes received for small files (files that only require reading one chunk from the stream).
Expected behavior
If the number of bytes received in a stream is small, it should be able to correctly set the content-length header so anything the stream is piped into can reference it.
Code to reproduce
Checklist