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

Range requests retrieve one extra byte #375

Open
andreasg123 opened this issue Jul 13, 2023 · 0 comments
Open

Range requests retrieve one extra byte #375

andreasg123 opened this issue Jul 13, 2023 · 0 comments

Comments

@andreasg123
Copy link

Range requests request one extra byte because the end of the range is specified as the byte after the range and not the last byte of the range. I could submit a PR if desired but the fix is trivial.

--- a/src/source/remote.js
+++ b/src/source/remote.js
@@ -55,7 +55,7 @@ class RemoteSource extends BaseSource {
       headers: {
         ...this.headers,
         Range: `bytes=${slices
-          .map(({ offset, length }) => `${offset}-${offset + length}`)
+          .map(({ offset, length }) => `${offset}-${offset + length - 1}`)
           .join(',')
         }`,
       },
@@ -111,7 +111,7 @@ class RemoteSource extends BaseSource {
     const response = await this.client.request({
       headers: {
         ...this.headers,
-        Range: `bytes=${offset}-${offset + length}`,
+        Range: `bytes=${offset}-${offset + length - 1}`,
       },
       signal,
     });
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