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

Using Range headers for more than just bytes #623

Open
mrjoops opened this issue Nov 10, 2023 · 0 comments
Open

Using Range headers for more than just bytes #623

mrjoops opened this issue Nov 10, 2023 · 0 comments

Comments

@mrjoops
Copy link

mrjoops commented Nov 10, 2023

Hi all!

This is a feature request.

As an API designer and Oak user, I was looking for the HTTP Range header support in Oak and was pleased to see it is actually supported... with some limitation: it can only accept bytes ranges, as cruelly written in the parseRange function in range.ts:

  if (unit !== "bytes") {
    throw createHttpError(Status.RequestedRangeNotSatisfiable);
  }

However the RFC is a bit less limiting on this particular subject (see https://datatracker.ietf.org/doc/html/rfc9110/#section-14.1) as it notes "Range units are intended to be extensible".
I often use "items" and "pages" units myself for example.

I'm not a particularly talented Typescript developer but it doesn't seem to be such a big deal to implement and if we could agree on the approach, I could surely help.

We could introduce a GenericRange interface that ByteRange could extend, and update parseRange to return either GenericRange[] or ByteRange[], using the same condition you used to throw the exception. The rest of the code could be left untouched, to start.

Thank you for reading!

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

1 participant