Skip to content

Commit a2745ef

Browse files
committed
fix: stucked byte range requests
Due to an invalid check, the request throws even if it is valid. `total` from `parseContentRangeHeader` is the total amount of bytes of the stream but `totalBytes` from `request` is the total amount of bytes of the request that we can infer from `to` and `from`
1 parent 22d48fb commit a2745ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/p2p-media-loader-core/src/http-loader.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,13 @@ export class HttpRequestExecutor {
150150
? parseContentRangeHeader(contentRangeHeader)
151151
: undefined;
152152
if (contentRange) {
153-
const { from, to, total } = contentRange;
153+
const { from, to } = contentRange;
154+
const totalBytes = to !== undefined && from !== undefined
155+
? to - from + 1
156+
: undefined
157+
154158
if (
155-
(total !== undefined && this.request.totalBytes !== total) ||
159+
(totalBytes !== undefined && this.request.totalBytes !== totalBytes) ||
156160
(from !== undefined && requestByteRange.start !== from) ||
157161
(to !== undefined &&
158162
requestByteRange.end !== undefined &&

0 commit comments

Comments
 (0)