Add middleware and authz support for server-side handlers (#733)

This commit is contained in:
Stephen Halter 2025-09-10 10:07:45 -07:00 • committed by GitHub
commit d344c65120
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,15 +100,17 @@ internal sealed class StreamableHttpSession(
try
{
await _disposeCts.CancelAsync();
try
{
// Dispose transport first to complete the incoming MessageReader gracefully and avoid a potentially unnecessary OCE.
await transport.DisposeAsync();
await _disposeCts.CancelAsync();
await ServerRunTask;
}
finally
{
await DisposeServerThenTransportAsync();
await server.DisposeAsync();
}
}
catch (OperationCanceledException)
@ -124,18 +126,6 @@ internal sealed class StreamableHttpSession(
}
}
private async ValueTask DisposeServerThenTransportAsync()
{
try
{
await server.DisposeAsync();
}
finally
{
await transport.DisposeAsync();
}
}
private sealed class UnreferenceDisposable(StreamableHttpSession session) : IAsyncDisposable
{
public ValueTask DisposeAsync()