Skip to content

Commit d8038b0

Browse files
committed
Add test
1 parent c35da60 commit d8038b0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/Servers/Kestrel/test/InMemory.FunctionalTests/UpgradeTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,38 @@ await connection.Receive("HTTP/1.1 101 Switching Protocols",
343343
await appCompletedTcs.Task.DefaultTimeout();
344344
}
345345
}
346+
347+
[Fact]
348+
public async Task DoesNotCloseConnectionWithout101Response()
349+
{
350+
var requestCount = 0;
351+
352+
await using (var server = new TestServer(async context =>
353+
{
354+
if (requestCount++ > 0)
355+
{
356+
await context.Features.Get<IHttpUpgradeFeature>().UpgradeAsync();
357+
}
358+
}, new TestServiceContext(LoggerFactory)))
359+
{
360+
using (var connection = server.CreateConnection())
361+
{
362+
await connection.SendEmptyGetWithUpgrade();
363+
await connection.Receive(
364+
"HTTP/1.1 200 OK",
365+
$"Date: {server.Context.DateHeaderValue}",
366+
"Content-Length: 0",
367+
"",
368+
"");
369+
370+
await connection.SendEmptyGetWithUpgrade();
371+
await connection.Receive("HTTP/1.1 101 Switching Protocols",
372+
"Connection: Upgrade",
373+
$"Date: {server.Context.DateHeaderValue}",
374+
"",
375+
"");
376+
}
377+
}
378+
}
346379
}
347380
}

0 commit comments

Comments
 (0)