Skip to content

Commit a0eba61

Browse files
authored
fix: Do not read from stream with content length of 0 (#629)
1 parent c305921 commit a0eba61

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: src/Docker.DotNet/Microsoft.Net.Http.Client/ContentLengthReadStream.cs

+12
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ public override int Read(byte[] buffer, int offset, int count)
9393
{
9494
return 0;
9595
}
96+
97+
if (_bytesRemaining == 0)
98+
{
99+
return 0;
100+
}
101+
96102
int toRead = (int)Math.Min(count, _bytesRemaining);
97103
int read = _inner.Read(buffer, offset, toRead);
98104
UpdateBytesRemaining(read);
@@ -106,6 +112,12 @@ public async override Task<int> ReadAsync(byte[] buffer, int offset, int count,
106112
{
107113
return 0;
108114
}
115+
116+
if (_bytesRemaining == 0)
117+
{
118+
return 0;
119+
}
120+
109121
cancellationToken.ThrowIfCancellationRequested();
110122
int toRead = (int)Math.Min(count, _bytesRemaining);
111123
int read = await _inner.ReadAsync(buffer, offset, toRead, cancellationToken);

0 commit comments

Comments
 (0)