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: full range header support #141

Merged
merged 1 commit into from
Jul 25, 2022
Merged

Conversation

vasco-santos
Copy link
Contributor

@vasco-santos vasco-santos commented Jun 3, 2022

This PR adds range header support to both content requested to Cache API, as well as from perma cache. The headers already go to the race as well, so race already does range

Needs:

Closes #77

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 3, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: bf813c4
Status: ✅  Deploy successful!
Preview URL: https://a2c2178e.nftstorage-link.pages.dev
Branch Preview URL: https://feat-range-header-support.nftstorage-link.pages.dev

View logs

if (r2Object) {
return new Response(r2Object.body)
return new Response(r2Object.body, {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const parts = encoded.split('bytes=')[1]?.split('-') ?? []
if (parts.length !== 2) {
throw new InvalidRangeError(
'Not supported to skip specifying the beginning/ending byte at this time'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasco-santos vasco-santos force-pushed the feat/range-header-support branch 2 times, most recently from 5cd00ff to 44eb2ab Compare June 28, 2022 13:27
@vasco-santos vasco-santos force-pushed the feat/range-header-support branch 3 times, most recently from dedae51 to ab25929 Compare June 30, 2022 14:29
[cache.match(request.url), getFromPermaCache(request, env)],
[
cache.match(request), // Request from cache API
cache.match(request.url), // Request URL from cache API - To be deprecated
Copy link
Contributor Author

@vasco-santos vasco-santos Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to have this for sometime until cache LRU cycles. Let's say 24H?

@vasco-santos vasco-santos changed the title feat: range header support feat: full range header support Jul 25, 2022
@vasco-santos vasco-santos merged commit 1336d21 into main Jul 25, 2022
@vasco-santos vasco-santos deleted the feat/range-header-support branch July 25, 2022 08:43
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.

Range header support
2 participants