Skip to content

Commit f4f1013

Browse files
committed
[Modify] Polish it
1 parent 11b6f16 commit f4f1013

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

websocket-sharp/Net/HttpListenerResponse.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,12 +931,22 @@ public void CopyFrom (HttpListenerResponse templateResponse)
931931
/// </exception>
932932
public void Redirect (string url)
933933
{
934-
checkDisposedOrHeadersSent ();
934+
if (_disposed)
935+
throw new ObjectDisposedException (GetType ().ToString ());
936+
937+
if (_headersSent) {
938+
var msg = "The response is already being sent.";
939+
throw new InvalidOperationException (msg);
940+
}
941+
935942
if (url == null)
936943
throw new ArgumentNullException ("url");
937944

938-
Uri uri = null;
939-
if (!url.MaybeUri () || !Uri.TryCreate (url, UriKind.Absolute, out uri))
945+
if (!url.MaybeUri ())
946+
throw new ArgumentException ("Not an absolute URL.", "url");
947+
948+
Uri uri;
949+
if (!Uri.TryCreate (url, UriKind.Absolute, out uri))
940950
throw new ArgumentException ("Not an absolute URL.", "url");
941951

942952
_location = url;

0 commit comments

Comments
 (0)