Skip to content

Commit 752d83a

Browse files
author
ladeak
committed
Adding the sse endpoint to the test server
1 parent d8a3dc5 commit 752d83a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/CHttpServer.Tests/TestServer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ async IAsyncEnumerable<string> GetStream()
8383
}
8484
return GetStream();
8585
});
86+
_app.MapGet("/sse", (HttpContext ctx) =>
87+
{
88+
async IAsyncEnumerable<string> GetStream()
89+
{
90+
foreach (var i in Enumerable.Range(0, 2))
91+
{
92+
await Task.Delay(1000);
93+
yield return "some content";
94+
}
95+
}
96+
return Results.ServerSentEvents(GetStream());
97+
});
8698
_app.MapGet("/headerstrailers", async (HttpContext ctx) =>
8799
{
88100
if (!ctx.Request.Headers.Accept.Contains("application/json") || ctx.Request.Headers["x-custom"] != "custom-header-value")

0 commit comments

Comments
 (0)