提交 0649fb4a 编写于 作者: M Marek Habersack

[asp.net] Handle closed responses gracefully.

If ReleaseResources or Flush (true) were called, a flag is set that causes
any subsequent Flush () calls to fail with an exception.
At the same time, ReleaseResources does not destroy the output stream completely -
it has to remain around to match .NET behavior.
上级 07dd1d37
......@@ -99,6 +99,7 @@ namespace System.Web
internal bool use_chunked;
bool closed;
bool completed;
internal bool suppress_content;
//
......@@ -801,6 +802,9 @@ namespace System.Web
internal void Flush (bool final_flush)
{
if (completed)
throw new HttpException ("Server cannot flush a completed response");
DoFilter (final_flush);
if (!headers_sent){
if (final_flush || status_code != 200)
......@@ -814,9 +818,11 @@ namespace System.Web
output_stream.Clear ();
if (WorkerRequest != null)
output_stream.Flush (WorkerRequest, true); // ignore final_flush here.
completed = true;
return;
}
completed = final_flush;
if (!headers_sent)
WriteHeaders (final_flush);
......@@ -1321,8 +1327,12 @@ namespace System.Web
internal void ReleaseResources ()
{
if (completed)
return;
output_stream.ReleaseResources (true);
output_stream = null;
Close ();
completed = true;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册