Skip to content

fix: serve zero-size files with proper content#311

Open
driphtyio wants to merge 1 commit into
pillarjs:masterfrom
driphtyio:main
Open

fix: serve zero-size files with proper content#311
driphtyio wants to merge 1 commit into
pillarjs:masterfrom
driphtyio:main

Conversation

@driphtyio

Copy link
Copy Markdown

When stat.size === 0 (e.g. /proc virtual filesystem files), the send() method was setting opts.end = 0 and Content-Length: 0, causing the read stream to stop at byte 0 and the response to be empty.

This fix guards opts.end and Content-Length with len > 0. When size is 0, the read stream continues until EOF and Node.js uses chunked transfer encoding, which correctly serves zero-size-but-readable files.

Fixes expressjs/express#4944

When stat.size === 0 (e.g. /proc virtual filesystem files),
don't limit the read stream to byte 0 and don't set
Content-Length: 0. Let the stream read until EOF and use
chunked transfer encoding.

Fixes expressjs/express#4944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

response.download does not return /proc/* files

1 participant