diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 82bf252e..1652e514 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -264,9 +264,15 @@ namespace WebSocketSharp.Net } set { - if (value != null && value.State != HttpHeaderType.Response) - throw new InvalidOperationException ( - "The specified headers aren't valid for a response."); + if (value == null) { + _headers = null; + return; + } + + if (value.State != HttpHeaderType.Response) { + var msg = "The value is not valid for a response."; + throw new InvalidOperationException (msg); + } _headers = value; }