Skip to content

Commit

Permalink
Workaround for an issue writing response after browser has closed con…
Browse files Browse the repository at this point in the history
…nection
  • Loading branch information
unknown authored and unknown committed May 20, 2010
1 parent 6eee862 commit 1537210
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/OpenRasta/Hosting/HttpListener/HttpListenerResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ public void WriteHeaders()
HeadersSent = true;
_nativeResponse.ContentLength64 = Headers.ContentLength.GetValueOrDefault();

_tempStream.WriteTo(_nativeResponse.OutputStream);
// Guard against a possible HttpListenerException : The specified network name is no longer available
try
{
_tempStream.WriteTo(_nativeResponse.OutputStream);
}
catch (Exception ex)

This comment has been minimized.

Copy link
@SteveDunn

SteveDunn May 27, 2010

Why not catch a more specific exception?

{
if (_context != null)

This comment has been minimized.

Copy link
@SteveDunn

SteveDunn May 27, 2010

Why would _context ever be null?

_context.ServerErrors.Add(new Error { Message = ex.ToString() });

This comment has been minimized.

Copy link
@SteveDunn

SteveDunn May 27, 2010

Would be nice to store the exception itself, then we'd retain any stack-trace information, inner exceptions etc.

}
}
}
}

0 comments on commit 1537210

Please sign in to comment.