Don't throw in HttpRequestStream.Flush (#2342)
Because read-only streams apparently can have Flush semantics and this behavior is expected by some of built-in stream wrappers (e. g. CryptoStream) https://github.com/dotnet/corefx/pull/27327#pullrequestreview-98384813 https://github.com/aspnet/KestrelHttpServer/issues/2341
This commit is contained in:
parent
6728e756b7
commit
39951e892e
|
|
@ -38,12 +38,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
||||||
public override void Flush()
|
public override void Flush()
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task FlushAsync(CancellationToken cancellationToken)
|
public override Task FlushAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long Seek(long offset, SeekOrigin origin)
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
|
|
||||||
|
|
@ -98,17 +98,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FlushThrows()
|
// Read-only streams should support Flush according to https://github.com/dotnet/corefx/pull/27327#pullrequestreview-98384813
|
||||||
|
public void FlushDoesNotThrow()
|
||||||
{
|
{
|
||||||
var stream = new HttpRequestStream(Mock.Of<IHttpBodyControlFeature>());
|
var stream = new HttpRequestStream(Mock.Of<IHttpBodyControlFeature>());
|
||||||
Assert.Throws<NotSupportedException>(() => stream.Flush());
|
stream.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task FlushAsyncThrows()
|
public async Task FlushAsyncDoesNotThrow()
|
||||||
{
|
{
|
||||||
var stream = new HttpRequestStream(Mock.Of<IHttpBodyControlFeature>());
|
var stream = new HttpRequestStream(Mock.Of<IHttpBodyControlFeature>());
|
||||||
await Assert.ThrowsAsync<NotSupportedException>(() => stream.FlushAsync());
|
await stream.FlushAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue