From bb790904086e99d5764805ea9c4011e9dd2adf97 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Mar 2020 22:23:46 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5de951d1..b108002a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -826,13 +826,20 @@ namespace WebSocketSharp.Net if (_state == HttpHeaderType.Unspecified) return; - if (response && _state == HttpHeaderType.Request) - throw new InvalidOperationException ( - "This collection has already been used to store the request headers."); + if (response) { + if (_state == HttpHeaderType.Response) + return; - if (!response && _state == HttpHeaderType.Response) - throw new InvalidOperationException ( - "This collection has already been used to store the response headers."); + var msg = "This collection has already been used for the request headers."; + + throw new InvalidOperationException (msg); + } + + if (_state == HttpHeaderType.Response) { + var msg = "This collection has already been used for the response headers."; + + throw new InvalidOperationException (msg); + } } private static string checkValue (string value)