Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting content-length #440

Closed
2 tasks done
gsimko opened this issue Feb 20, 2024 · 5 comments
Closed
2 tasks done

setting content-length #440

gsimko opened this issue Feb 20, 2024 · 5 comments

Comments

@gsimko
Copy link

gsimko commented Feb 20, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

I propose to set content-length when it's available. I'm using the preCompressed option so the size is trivially available. I'm less certain whether it is doable for on-the-fly encoding. Wdyt?

Motivation

No response

Example

No response

@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@gurgunday
Copy link
Member

This feature would be a good addition, and it would be even better if we could do it for uncompressed files as well (by using statSync or something)

@gurgunday gurgunday added the feature request New feature to be added label Feb 23, 2024
@gsimko
Copy link
Author

gsimko commented Feb 25, 2024

Looks like this is not a fastify problem.
Fastify-static relies on fastify-send and that one already sets content-length by using stat. By locally running the query and checking the response I could confirm that it's set.

In my case it must be some other component that's causing the trouble. I noticed that the browser uses http2 requests while I configured fastify to use http1 so there must be a proxy somewhere in the setup doing the conversion. I guess that one drops the content-length header. @gurgunday could that explain why you also observed this problem?

@gurgunday
Copy link
Member

gurgunday commented Feb 25, 2024

That's interesting, I don't see the header in my production app either, let me try on localhost and come back on this

@gurgunday
Copy link
Member

Oh yeah, it's compress that's removing it for me, which makes sense

It might indeed be a proxy like Cloudflare that's dropping it too

Closing the issue if you don't have any other problems, feel free to comment again otherwise

@gurgunday gurgunday removed the feature request New feature to be added label Feb 25, 2024
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

No branches or pull requests

3 participants