#1253 TestServer: mark response headers IsReadOnly on start

This commit is contained in:
Chris Ross (ASP.NET) 2017-11-06 22:15:19 -08:00
parent 65bad5b9ab
commit 1e556e0b46
2 changed files with 4 additions and 1 deletions

View File

@ -13,10 +13,11 @@ namespace Microsoft.AspNetCore.TestHost
{
private Func<Task> _responseStartingAsync = () => Task.FromResult(true);
private Func<Task> _responseCompletedAsync = () => Task.FromResult(true);
private HeaderDictionary _headers = new HeaderDictionary();
public ResponseFeature()
{
Headers = new HeaderDictionary();
Headers = _headers;
Body = new MemoryStream();
// 200 is the default status code all the way down to the host, so we set it
@ -69,6 +70,7 @@ namespace Microsoft.AspNetCore.TestHost
{
await _responseStartingAsync();
HasStarted = true;
_headers.IsReadOnly = true;
}
public Task FireOnResponseCompletedAsync()

View File

@ -22,6 +22,7 @@ namespace Microsoft.AspNetCore.TestHost
await responseInformation.FireOnSendingHeadersAsync();
Assert.True(responseInformation.HasStarted);
Assert.True(responseInformation.Headers.IsReadOnly);
}
[Fact]