Merge branch 'release/2.2'
This commit is contained in:
commit
d6c9fd8d43
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.ExceptionServices;
|
using System.Runtime.ExceptionServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -192,29 +193,32 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ValidateState(CancellationToken cancellationToken)
|
private void ValidateState(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
switch (_state)
|
var state = _state;
|
||||||
|
if (state == HttpStreamState.Open)
|
||||||
{
|
{
|
||||||
case HttpStreamState.Open:
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
if (cancellationToken.IsCancellationRequested)
|
|
||||||
{
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HttpStreamState.Closed:
|
|
||||||
throw new ObjectDisposedException(nameof(HttpRequestStream));
|
|
||||||
case HttpStreamState.Aborted:
|
|
||||||
if (_error != null)
|
|
||||||
{
|
|
||||||
ExceptionDispatchInfo.Capture(_error).Throw();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new TaskCanceledException();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (state == HttpStreamState.Closed)
|
||||||
|
{
|
||||||
|
ThrowObjectDisposedException();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_error != null)
|
||||||
|
{
|
||||||
|
ExceptionDispatchInfo.Capture(_error).Throw();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ThrowTaskCanceledException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThrowObjectDisposedException() => throw new ObjectDisposedException(nameof(HttpRequestStream));
|
||||||
|
void ThrowTaskCanceledException() => throw new TaskCanceledException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||||
|
|
@ -148,25 +149,23 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ValidateState(CancellationToken cancellationToken)
|
private void ValidateState(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
switch (_state)
|
var state = _state;
|
||||||
|
if (state == HttpStreamState.Open || state == HttpStreamState.Aborted)
|
||||||
{
|
{
|
||||||
case HttpStreamState.Open:
|
// Aborted state only throws on write if cancellationToken requests it
|
||||||
if (cancellationToken.IsCancellationRequested)
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
{
|
}
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
else
|
||||||
}
|
{
|
||||||
break;
|
ThrowObjectDisposedException();
|
||||||
case HttpStreamState.Closed:
|
}
|
||||||
throw new ObjectDisposedException(nameof(HttpResponseStream), CoreStrings.WritingToResponseBodyAfterResponseCompleted);
|
|
||||||
case HttpStreamState.Aborted:
|
void ThrowObjectDisposedException()
|
||||||
if (cancellationToken.IsCancellationRequested)
|
{
|
||||||
{
|
throw new ObjectDisposedException(nameof(HttpResponseStream), CoreStrings.WritingToResponseBodyAfterResponseCompleted);
|
||||||
// Aborted state only throws on write if cancellationToken requests it
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue