Skip to content

Commit

Permalink
Avoid to copy cancellation token
Browse files Browse the repository at this point in the history
  • Loading branch information
xsoheilalizadeh committed Jan 17, 2020
1 parent 3bb7a43 commit a33194e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/raccoonLog.Http/HttpMessageLogMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public HttpMessageLogMiddleware(RequestDelegate next)

public async Task Invoke(HttpContext context, IHttpLoggingProvider httpLogging)
{
var ct = context.RequestAborted;

await httpLogging.LogAsync(context.Request, ct);
await httpLogging.LogAsync(context.Request, context.RequestAborted);

var originalBody = context.Response.Body;

Expand All @@ -32,11 +30,11 @@ public async Task Invoke(HttpContext context, IHttpLoggingProvider httpLogging)

await _next(context);

await httpLogging.LogAsync(context.Response, bodyStream, ct);
await httpLogging.LogAsync(context.Response, bodyStream, context.RequestAborted);

bodyStream.Position = 0;

await bodyStream.CopyToAsync(originalBody, ct);
await bodyStream.CopyToAsync(originalBody, context.RequestAborted);

context.Response.Body = originalBody;
}
Expand Down

0 comments on commit a33194e

Please sign in to comment.