From 792f3ad08909c4ecd872eea043076447f1d70ae4 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Thu, 17 Mar 2016 23:01:42 -0700 Subject: [PATCH] Fix race preventing handling of the last request sent over a connection We need to attempt to consume start lines and headers even after SocketInput.RemoteIntakeFin is set to true to ensure we don't close a connection without giving the application a chance to respond to a request sent immediately before the a FIN from the client. --- .../Http/FrameOfT.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs index 053688b587..40a160a0fe 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs @@ -37,8 +37,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http { if (SocketInput.RemoteIntakeFin) { + if (TakeStartLine(SocketInput)) + { + break; + } + return; } + await SocketInput; } @@ -48,8 +54,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http { if (SocketInput.RemoteIntakeFin) { + if (TakeMessageHeaders(SocketInput, FrameRequestHeaders)) + { + break; + } + return; } + await SocketInput; }