diff options
Diffstat (limited to 'SocketHttpListener/Ext.cs')
| -rw-r--r-- | SocketHttpListener/Ext.cs | 128 |
1 files changed, 3 insertions, 125 deletions
diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 87f0887ed..125775180 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -7,9 +7,8 @@ using System.Net; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Services; -using SocketHttpListener.Net; -using HttpListenerResponse = SocketHttpListener.Net.HttpListenerResponse; using HttpStatusCode = SocketHttpListener.Net.HttpStatusCode; +using WebSocketState = System.Net.WebSockets.WebSocketState; namespace SocketHttpListener { @@ -129,7 +128,7 @@ namespace SocketHttpListener internal static string CheckIfClosable(this WebSocketState state) { - return state == WebSocketState.Closing + return state == WebSocketState.CloseSent ? "While closing the WebSocket connection." : state == WebSocketState.Closed ? "The WebSocket connection has already been closed." @@ -140,7 +139,7 @@ namespace SocketHttpListener { return state == WebSocketState.Connecting ? "A WebSocket connection isn't established." - : state == WebSocketState.Closing + : state == WebSocketState.CloseSent ? "While closing the WebSocket connection." : state == WebSocketState.Closed ? "The WebSocket connection has already been closed." @@ -154,20 +153,6 @@ namespace SocketHttpListener : null; } - internal static string CheckIfValidSendData(this byte[] data) - { - return data == null - ? "'data' must not be null." - : null; - } - - internal static string CheckIfValidSendData(this string data) - { - return data == null - ? "'data' must not be null." - : null; - } - internal static Stream Compress(this Stream stream, CompressionMethod method) { return method == CompressionMethod.Deflate @@ -632,24 +617,6 @@ namespace SocketHttpListener } /// <summary> - /// Emits the specified <see cref="EventHandler"/> delegate if it isn't <see langword="null"/>. - /// </summary> - /// <param name="eventHandler"> - /// A <see cref="EventHandler"/> to emit. - /// </param> - /// <param name="sender"> - /// An <see cref="object"/> from which emits this <paramref name="eventHandler"/>. - /// </param> - /// <param name="e"> - /// A <see cref="EventArgs"/> that contains no event data. - /// </param> - public static void Emit(this EventHandler eventHandler, object sender, EventArgs e) - { - if (eventHandler != null) - eventHandler(sender, e); - } - - /// <summary> /// Emits the specified <c>EventHandler<TEventArgs></c> delegate /// if it isn't <see langword="null"/>. /// </summary> @@ -674,27 +641,6 @@ namespace SocketHttpListener } /// <summary> - /// Gets the collection of the HTTP cookies from the specified HTTP <paramref name="headers"/>. - /// </summary> - /// <returns> - /// A <see cref="CookieCollection"/> that receives a collection of the HTTP cookies. - /// </returns> - /// <param name="headers"> - /// A <see cref="QueryParamCollection"/> that contains a collection of the HTTP headers. - /// </param> - /// <param name="response"> - /// <c>true</c> if <paramref name="headers"/> is a collection of the response headers; - /// otherwise, <c>false</c>. - /// </param> - public static CookieCollection GetCookies(this QueryParamCollection headers, bool response) - { - var name = response ? "Set-Cookie" : "Cookie"; - return headers == null || !headers.Contains(name) - ? new CookieCollection() - : CookieHelper.Parse(headers[name], response); - } - - /// <summary> /// Gets the description of the specified HTTP status <paramref name="code"/>. /// </summary> /// <returns> @@ -709,52 +655,6 @@ namespace SocketHttpListener } /// <summary> - /// Gets the name from the specified <see cref="string"/> that contains a pair of name and - /// value separated by a separator string. - /// </summary> - /// <returns> - /// A <see cref="string"/> that represents the name if any; otherwise, <c>null</c>. - /// </returns> - /// <param name="nameAndValue"> - /// A <see cref="string"/> that contains a pair of name and value separated by a separator - /// string. - /// </param> - /// <param name="separator"> - /// A <see cref="string"/> that represents a separator string. - /// </param> - public static string GetName(this string nameAndValue, string separator) - { - return (nameAndValue != null && nameAndValue.Length > 0) && - (separator != null && separator.Length > 0) - ? nameAndValue.GetNameInternal(separator) - : null; - } - - /// <summary> - /// Gets the name and value from the specified <see cref="string"/> that contains a pair of - /// name and value separated by a separator string. - /// </summary> - /// <returns> - /// A <c>KeyValuePair<string, string></c> that represents the name and value if any. - /// </returns> - /// <param name="nameAndValue"> - /// A <see cref="string"/> that contains a pair of name and value separated by a separator - /// string. - /// </param> - /// <param name="separator"> - /// A <see cref="string"/> that represents a separator string. - /// </param> - public static KeyValuePair<string, string> GetNameAndValue( - this string nameAndValue, string separator) - { - var name = nameAndValue.GetName(separator); - var value = nameAndValue.GetValue(separator); - return name != null - ? new KeyValuePair<string, string>(name, value) - : new KeyValuePair<string, string>(null, null); - } - - /// <summary> /// Gets the description of the specified HTTP status <paramref name="code"/>. /// </summary> /// <returns> @@ -819,28 +719,6 @@ namespace SocketHttpListener } /// <summary> - /// Gets the value from the specified <see cref="string"/> that contains a pair of name and - /// value separated by a separator string. - /// </summary> - /// <returns> - /// A <see cref="string"/> that represents the value if any; otherwise, <c>null</c>. - /// </returns> - /// <param name="nameAndValue"> - /// A <see cref="string"/> that contains a pair of name and value separated by a separator - /// string. - /// </param> - /// <param name="separator"> - /// A <see cref="string"/> that represents a separator string. - /// </param> - public static string GetValue(this string nameAndValue, string separator) - { - return (nameAndValue != null && nameAndValue.Length > 0) && - (separator != null && separator.Length > 0) - ? nameAndValue.GetValueInternal(separator) - : null; - } - - /// <summary> /// Determines whether the specified <see cref="ByteOrder"/> is host /// (this computer architecture) byte order. /// </summary> |
