Skip to content

Commit

Permalink
Slight performance improvement using StreamContent than MemoryStream
Browse files Browse the repository at this point in the history
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
  • Loading branch information
WhitWaldo committed Feb 11, 2025
1 parent 171d48b commit a37a5a7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Dapr.Jobs/Extensions/EndpointRouteBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ public static IEndpointRouteBuilder MapDaprScheduledJobHandler(this IEndpointRou
ReadOnlyMemory<byte> payload = new();
if (context.Request.ContentLength is > 0)
{
using var memoryStream = new MemoryStream();
await context.Request.Body.CopyToAsync(memoryStream, cancellationToken);
payload = memoryStream.ToArray();
using var streamContent = new StreamContent(context.Request.Body);
payload = await streamContent.ReadAsByteArrayAsync(cancellationToken);
}

var parameters = new Dictionary<Type, object>
Expand Down

0 comments on commit a37a5a7

Please sign in to comment.