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 · 2 comments
Open

Range requests retrieve one extra byte #375

andreasg123 opened this issue Jul 13, 2023 · 2 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,
     });
@jcphill
Copy link
Contributor

jcphill commented Dec 16, 2024

Would also want to fix this:

length: end - start,

@jcphill
Copy link
Contributor

jcphill commented Dec 16, 2024

FYI, the similar pull request #443 was rejected with a reference to #112, which was apparently merged but then reverted by d984d7c

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

2 participants