Skip to content

Commit 74b1c14

Browse files
author
ladeak
committed
Stream and SSE endpoints for H/3 testing in the TestCHttp application
1 parent a3566eb commit 74b1c14

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • src/CHttpServer/TestCHttpServerApplication

src/CHttpServer/TestCHttpServerApplication/Program.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,26 @@
5454

5555
app.MapGet("/echo", context => context.Request.Body.CopyToAsync(context.Response.Body));
5656

57+
app.MapGet("/stream", Streaming);
58+
59+
app.MapGet("/streamraw", StreamingRaw);
60+
5761
app.Run();
5862

63+
async IAsyncEnumerable<string> StreamingRaw()
64+
{
65+
for (int i = 0; i < 100; i++)
66+
{
67+
await Task.Delay(1000);
68+
yield return i.ToString();
69+
}
70+
}
71+
72+
IResult Streaming()
73+
{
74+
return Results.ServerSentEvents<string>(StreamingRaw());
75+
}
76+
5977
public class Data
6078
{
6179
public required string Message { get; set; }

0 commit comments

Comments
 (0)