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

feat: add Content-Length Header when possible #165

Open
lhns opened this issue Dec 23, 2024 · 2 comments
Open

feat: add Content-Length Header when possible #165

lhns opened this issue Dec 23, 2024 · 2 comments
Labels
dif/medium Prior experience is likely helpful effort/days Estimated to take multiple days, but less than a week kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked

Comments

@lhns
Copy link

lhns commented Dec 23, 2024

Is it possible to know the object size before downloading?
This would allow showing a detailed progress bar for example.
If so it could be added as the Content-Length header to the response object.

@SgtPooki
Copy link
Member

SgtPooki commented Jan 6, 2025

There are some cases in which we may know the content length, and we should add the header in those cases IMHO, but it's not currently specified in the trustless gateway specification, which we're targeting first with @helia/verified-fetch.

There are still some unknowns and things to clarify here, but we might be able to add a content-length header in some cases.

Relevant specs & issues:


For now, you may be able to use HTTP Range request headers to figure out more about the size of the content you're fetching.

E.g. Range: bytes=0-

And then you would get back a content-range header in the response with the size (if we can determine it): Content-Range: <unit> <range-start>-<range-end>/<size>

The logic for byte range handling is in https://github.com/ipfs/helia-verified-fetch/blob/main/packages/verified-fetch/src/utils/byte-range-context.ts

@lhns
Copy link
Author

lhns commented Jan 7, 2025

This works very well for me, thank you! I also found out that the onProgress event tells me the file size.

@SgtPooki SgtPooki changed the title Content-Length Header feat: add Content-Length Header when possible Feb 11, 2025
@SgtPooki SgtPooki added P2 Medium: Good to have, but can wait until someone steps up dif/medium Prior experience is likely helpful effort/days Estimated to take multiple days, but less than a week kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding status/ready Ready to be worked labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dif/medium Prior experience is likely helpful effort/days Estimated to take multiple days, but less than a week kind/enhancement A net-new feature or improvement to an existing feature need/analysis Needs further analysis before proceeding P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

2 participants