diff --git a/src/GaudiHTTP.IntegrationTests.End2End/H11/ServerStartupReliabilitySpec.cs b/src/GaudiHTTP.IntegrationTests.End2End/H11/ServerStartupReliabilitySpec.cs index e9ec2f5b..7cf18b5b 100644 --- a/src/GaudiHTTP.IntegrationTests.End2End/H11/ServerStartupReliabilitySpec.cs +++ b/src/GaudiHTTP.IntegrationTests.End2End/H11/ServerStartupReliabilitySpec.cs @@ -84,6 +84,7 @@ public async Task Server_with_three_listeners_should_respond_to_first_h11_reques } finally { + Servus.Senf.Tracing.Disable(); cert.Dispose(); } } diff --git a/src/GaudiHTTP/Streams/Stages/Server/HttpServerConnectionStageLogic.cs b/src/GaudiHTTP/Streams/Stages/Server/HttpServerConnectionStageLogic.cs index ae21d77b..3ff59f4d 100644 --- a/src/GaudiHTTP/Streams/Stages/Server/HttpServerConnectionStageLogic.cs +++ b/src/GaudiHTTP/Streams/Stages/Server/HttpServerConnectionStageLogic.cs @@ -523,6 +523,15 @@ private void CloseAllPorts() Cancel(_inResponse); } + if (_outboundQueue.Count > 0) + { + // Outbound data is still queued (e.g. response encoded but not yet pushed + // because the network outlet had no demand). Drain via the flush path so + // the data reaches the transport before the connection closes. + CompleteAfterFlushingOutbound(); + return; + } + if (!IsClosed(_outNetwork)) { Complete(_outNetwork);