Skip to content

Commit

Permalink
Skip copy when non-seekable stream
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinjahn committed Dec 9, 2024
1 parent 752845c commit 4fd91fc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/http/httpClient/Middleware/BodyInspectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,18 @@ CancellationToken cancellationToken
return null;
}

if (httpContent.Headers.ContentLength == 0)
{
return Stream.Null;
}

var stream = new MemoryStream();
await httpContent.CopyToAsync(stream);
stream.Position = 0;

if (stream.CanSeek)
{
stream.Position = 0;
}

return stream;
}
Expand Down

0 comments on commit 4fd91fc

Please sign in to comment.