-
-
Notifications
You must be signed in to change notification settings - Fork 572
Handle content length being null in StreamClient #939
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,8 +113,7 @@ private async IAsyncEnumerable<IStreamInfo> GetStreamInfosAsync( | |
| } | ||
|
|
||
| var contentLength = await TryGetContentLengthAsync(streamData, url, cancellationToken); | ||
| if (contentLength is null) | ||
| continue; | ||
| var fileSize = contentLength is null ? new FileSize() : new FileSize(contentLength.Value); | ||
|
||
|
|
||
| var container = | ||
| streamData.Container?.Pipe(s => new Container(s)) | ||
|
|
@@ -151,7 +150,7 @@ streamData.VideoWidth is not null && streamData.VideoHeight is not null | |
| var streamInfo = new MuxedStreamInfo( | ||
| url, | ||
| container, | ||
| new FileSize(contentLength.Value), | ||
| fileSize, | ||
| bitrate, | ||
| streamData.AudioCodec, | ||
| audioLanguage, | ||
|
|
@@ -169,7 +168,7 @@ streamData.VideoWidth is not null && streamData.VideoHeight is not null | |
| var streamInfo = new VideoOnlyStreamInfo( | ||
| url, | ||
| container, | ||
| new FileSize(contentLength.Value), | ||
| fileSize, | ||
| bitrate, | ||
| streamData.VideoCodec, | ||
| videoQuality, | ||
|
|
@@ -185,7 +184,7 @@ streamData.VideoWidth is not null && streamData.VideoHeight is not null | |
| var streamInfo = new AudioOnlyStreamInfo( | ||
| url, | ||
| container, | ||
| new FileSize(contentLength.Value), | ||
| fileSize, | ||
| bitrate, | ||
| streamData.AudioCodec, | ||
| audioLanguage, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contentLengthbeing null is now represented asnew FileSize()(0 bytes). This is not equivalent to “unknown size” and will break downstream logic that relies on a real size (e.g.,MediaStream.Length/segmenting usesstreamInfo.Size.Bytes; a 0 length causes reads to terminate immediately and can yield empty downloads). Consider keeping size nullable (API change) or adding an explicit “unknown” representation and updating consumers (MediaStream, progress reporting) to handle unknown length without using 0 as a sentinel, or alternatively derive the length via a range request whenContent-Lengthis absent.