From f4f101384a64359576ff6b61bce498a813aca6aa Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Nov 2019 21:50:32 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a3b5efd0..c532d73f 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -931,12 +931,22 @@ namespace WebSocketSharp.Net /// public void Redirect (string url) { - checkDisposedOrHeadersSent (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + if (url == null) throw new ArgumentNullException ("url"); - Uri uri = null; - if (!url.MaybeUri () || !Uri.TryCreate (url, UriKind.Absolute, out uri)) + if (!url.MaybeUri ()) + throw new ArgumentException ("Not an absolute URL.", "url"); + + Uri uri; + if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "url"); _location = url;