Skip to content

Commit 7e405e0

Browse files
Copilotgimlichael
andauthored
fix: prevent StreamWriter from disposing HttpResponse.Body in ConfigurableResponseNegotiator (#4)
* Initial plan * fix: use leaveOpen:true in StreamWriter to avoid disposing HttpResponse.Body Co-authored-by: gimlichael <8550919+gimlichael@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gimlichael <8550919+gimlichael@users.noreply.github.com>
1 parent fe63839 commit 7e405e0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Codebelt.Extensions.Carter/Response/ConfigurableResponseNegotiator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public virtual async Task Handle<T>(HttpRequest req, HttpResponse res, T model,
113113
{
114114
var encoding = GetEncoding(req);
115115
res.ContentType = ContentType + "; charset=" + encoding.WebName;
116-
await using var textWriter = new StreamWriter(res.Body, encoding);
116+
await using var textWriter = new StreamWriter(res.Body, encoding, bufferSize: -1, leaveOpen: true);
117117
var formatter = GetFormatter();
118118
using (var streamReader = new StreamReader(formatter.Serialize(model), encoding))
119119
{

0 commit comments

Comments
 (0)