Skip to content

Commit

Permalink
fix: Do not read from stream with content length of 0 (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed May 15, 2023
1 parent c305921 commit a0eba61
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ public override int Read(byte[] buffer, int offset, int count)
{
return 0;
}

if (_bytesRemaining == 0)
{
return 0;
}

int toRead = (int)Math.Min(count, _bytesRemaining);
int read = _inner.Read(buffer, offset, toRead);
UpdateBytesRemaining(read);
Expand All @@ -106,6 +112,12 @@ public async override Task<int> ReadAsync(byte[] buffer, int offset, int count,
{
return 0;
}

if (_bytesRemaining == 0)
{
return 0;
}

cancellationToken.ThrowIfCancellationRequested();
int toRead = (int)Math.Min(count, _bytesRemaining);
int read = await _inner.ReadAsync(buffer, offset, toRead, cancellationToken);
Expand Down

0 comments on commit a0eba61

Please sign in to comment.