Skip to content

Commit 32797b4

Browse files
committed
Call FlushAsync explicitly
1 parent b8ecf76 commit 32797b4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/BenchmarksApps/TechEmpower/Kestrel/BenchmarkApp.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private static async Task Index(IHttpRequestFeature req, IHttpResponseFeature re
5454

5555
await body.StartAsync();
5656
body.Writer.Write(IndexPayload);
57+
await body.Writer.FlushAsync();
5758
}
5859

5960
private static ReadOnlySpan<byte> HelloWorldPayload => "Hello, World!"u8;
@@ -67,6 +68,7 @@ private static async Task Plaintext(IHttpRequestFeature req, IHttpResponseFeatur
6768
var body = features.GetResponseBodyFeature();
6869
await body.StartAsync();
6970
body.Writer.Write(HelloWorldPayload);
71+
await body.Writer.FlushAsync();
7072
}
7173

7274
private static readonly JsonSerializerOptions _jsonSerializerOptions = new(JsonSerializerDefaults.Web);
@@ -93,6 +95,7 @@ private static async Task Json(IHttpRequestFeature req, IHttpResponseFeature res
9395

9496
await body.StartAsync();
9597
body.Writer.Write(bufferWriter.WrittenSpan);
98+
await body.Writer.FlushAsync();
9699

97100
_jsonWriterPool.Return(jsonWriter);
98101
_bufferWriterPool.Return(bufferWriter);
@@ -109,10 +112,6 @@ private class Utf8JsonWriterPooledObjectPolicy : IPooledObjectPolicy<Utf8JsonWri
109112

110113
public Utf8JsonWriter Create() => new(_dummyBufferWriter, new() { Indented = false, SkipValidation = true });
111114

112-
public bool Return(Utf8JsonWriter obj)
113-
{
114-
//obj.Reset();
115-
return true;
116-
}
115+
public bool Return(Utf8JsonWriter obj) => true;
117116
}
118117
}

0 commit comments

Comments
 (0)