Set HasStarted for StartAsync #16987 (#16993)

This commit is contained in:
Chris Ross 2019-11-11 15:32:32 -08:00 committed by GitHub
parent 20fc1adf2a
commit e336f4010a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -400,7 +400,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
set { _responseHeaders = value; } set { _responseHeaders = value; }
} }
bool IHttpResponseFeature.HasStarted => Response.HasStarted; bool IHttpResponseFeature.HasStarted => _responseStarted;
void IHttpResponseFeature.OnStarting(Func<object, Task> callback, object state) void IHttpResponseFeature.OnStarting(Func<object, Task> callback, object state)
{ {

View File

@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
return Task.CompletedTask; return Task.CompletedTask;
}); });
await httpContext.Response.StartAsync(); await httpContext.Response.StartAsync();
Assert.True(httpContext.Response.HasStarted);
Assert.True(httpContext.Response.Headers.IsReadOnly); Assert.True(httpContext.Response.Headers.IsReadOnly);
await startingTcs.Task.WithTimeout(); await startingTcs.Task.WithTimeout();
await httpContext.Response.WriteAsync("Hello World"); await httpContext.Response.WriteAsync("Hello World");
@ -58,6 +59,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
return Task.CompletedTask; return Task.CompletedTask;
}); });
await httpContext.Response.CompleteAsync(); await httpContext.Response.CompleteAsync();
Assert.True(httpContext.Response.HasStarted);
Assert.True(httpContext.Response.Headers.IsReadOnly); Assert.True(httpContext.Response.Headers.IsReadOnly);
await startingTcs.Task.WithTimeout(); await startingTcs.Task.WithTimeout();
await responseReceived.Task.WithTimeout(); await responseReceived.Task.WithTimeout();