Skip to content

Commit

Permalink
Update EncryptionResponseMiddleware.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoy8 committed Nov 11, 2023
1 parent 908e170 commit d0fe732
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Blog.Core.Extensions/Middlewares/EncryptionResponseMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ public async Task InvokeAsync(HttpContext context)
string resJson = JsonConvert.SerializeObject(new { response, msg, status, s, success });

context.Response.Clear();
await using var streamlriter = new StreamWriter(originalBodyStream, leaveOpen: true);
await streamlriter.WriteAsync(resJson);
responseCxt.ContentType = "application/json";

//var encryptedData = Encoding.UTF8.GetBytes(resJson);
//responseCxt.ContentLength = encryptedData.Length;
//await originalBodyStream.WriteAsync(encryptedData, 0, encryptedData.Length);
//await using var streamlriter = new StreamWriter(originalBodyStream, leaveOpen: true);
//await streamlriter.WriteAsync(resJson);

var encryptedData = Encoding.UTF8.GetBytes(resJson);
responseCxt.ContentLength = encryptedData.Length;
await originalBodyStream.WriteAsync(encryptedData, 0, encryptedData.Length);

responseCxt.Body = originalBodyStream;
}
}
else
Expand Down

0 comments on commit d0fe732

Please sign in to comment.