This commit is contained in:
parent
23f3a10965
commit
4dd9bfc492
|
|
@ -27,6 +27,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
|||
get { return _contentLength; }
|
||||
set
|
||||
{
|
||||
if (_isReadOnly)
|
||||
{
|
||||
ThrowHeadersReadOnlyException();
|
||||
}
|
||||
if (value.HasValue && value.Value < 0)
|
||||
{
|
||||
ThrowInvalidContentLengthException(value.Value);
|
||||
|
|
|
|||
|
|
@ -138,6 +138,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.Throws<InvalidOperationException>(() => ((IDictionary<string, StringValues>)headers).Add("my-header", new[] { "value" }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsWhenSettingContentLengthPropertyAfterReadOnlyIsSet()
|
||||
{
|
||||
var headers = new HttpResponseHeaders();
|
||||
headers.SetReadOnly();
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => headers.ContentLength = null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsWhenChangingHeaderAfterReadOnlyIsSet()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue