Prevent OnComplete modifying Streams
This commit is contained in:
parent
f5e45accac
commit
841ec73497
|
|
@ -91,6 +91,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
await FireOnStarting();
|
await FireOnStarting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_requestBody.PauseAcceptingReads();
|
||||||
|
_responseBody.PauseAcceptingWrites();
|
||||||
|
|
||||||
if (_onCompleted != null)
|
if (_onCompleted != null)
|
||||||
{
|
{
|
||||||
await FireOnCompleted();
|
await FireOnCompleted();
|
||||||
|
|
@ -101,10 +104,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
// If _requestAbort is set, the connection has already been closed.
|
// If _requestAbort is set, the connection has already been closed.
|
||||||
if (!_requestAborted)
|
if (!_requestAborted)
|
||||||
{
|
{
|
||||||
|
_responseBody.ResumeAcceptingWrites();
|
||||||
await ProduceEnd();
|
await ProduceEnd();
|
||||||
|
|
||||||
if (_keepAlive)
|
if (_keepAlive)
|
||||||
{
|
{
|
||||||
|
_requestBody.ResumeAcceptingReads();
|
||||||
// Finish reading the request body in case the app did not.
|
// Finish reading the request body in case the app did not.
|
||||||
await messageBody.Consume();
|
await messageBody.Consume();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,19 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PauseAcceptingReads()
|
||||||
|
{
|
||||||
|
_state = StreamState.Closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResumeAcceptingReads()
|
||||||
|
{
|
||||||
|
if (_state == StreamState.Closed)
|
||||||
|
{
|
||||||
|
_state = StreamState.Open;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void StopAcceptingReads()
|
public void StopAcceptingReads()
|
||||||
{
|
{
|
||||||
// Can't use dispose (or close) as can be disposed too early by user code
|
// Can't use dispose (or close) as can be disposed too early by user code
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,19 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PauseAcceptingWrites()
|
||||||
|
{
|
||||||
|
_state = StreamState.Closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResumeAcceptingWrites()
|
||||||
|
{
|
||||||
|
if (_state == StreamState.Closed)
|
||||||
|
{
|
||||||
|
_state = StreamState.Open;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void StopAcceptingWrites()
|
public void StopAcceptingWrites()
|
||||||
{
|
{
|
||||||
// Can't use dispose (or close) as can be disposed too early by user code
|
// Can't use dispose (or close) as can be disposed too early by user code
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue