This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix hang on Connection: close requests. (#406)

  • Loading branch information...
cesarbs committed Nov 20, 2015
1 parent 9d85263 commit e4fd91bb68f535801ca8a79aa453ea3fb3f448fe
@@ -279,8 +279,11 @@ public async Task RequestProcessingAsync()
{
await ProduceEnd();

// Finish reading the request body in case the app did not.
await messageBody.Consume();
if (_keepAlive)
{
// Finish reading the request body in case the app did not.
await messageBody.Consume();
}
}

_requestBody.StopAcceptingReads();
@@ -88,6 +88,37 @@ public Task RemoteIPv6Address()
return TestRemoteIPAddress("[::1]", "[::1]", "::1", "8792");
}

[ConditionalFact]
[FrameworkSkipCondition(RuntimeFrameworks.Mono, SkipReason = "Test hangs after execution on Mono.")]
public async Task DoesNotHangOnConnectionCloseRequest()
{
var config = new ConfigurationBuilder().AddInMemoryCollection(
new Dictionary<string, string> {
{ "server.urls", "http://localhost:8791" }
}).Build();

var builder = new WebHostBuilder(config)
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
.UseStartup(app =>
{
app.Run(async context =>
{
var connection = context.Connection;
await context.Response.WriteAsync("hello, world");
});
});

using (var app = builder.Build().Start())
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Connection.Clear();
client.DefaultRequestHeaders.Connection.Add("close");

var response = await client.GetAsync("http://localhost:8791/");
response.EnsureSuccessStatusCode();
}
}

private async Task TestRemoteIPAddress(string registerAddress, string requestAddress, string expectAddress, string port)
{
var config = new ConfigurationBuilder().AddInMemoryCollection(

1 comment on commit e4fd91b

@jincod

This comment has been minimized.

Copy link

jincod commented on e4fd91b Nov 24, 2015

Does it fix this issue?

Please sign in to comment.