diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 54119988..3520c0f3 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -782,6 +782,22 @@ namespace WebSocketSharp.Net base.Add (name, checkValue (value)); } + private void checkAllowed (bool response) + { + if (_state == HttpHeaderType.Unspecified) + return; + + var headerType = response + ? HttpHeaderType.Response + : HttpHeaderType.Request; + + if (headerType != _state) { + var msg = "This instance does not allow the header."; + + throw new InvalidOperationException (msg); + } + } + private void checkAllowed (string name) { if (_state == HttpHeaderType.Unspecified)