Ignore:
Timestamp:
Aug 1, 2022, 12:26:44 PM (3 years ago)
Author:
alloc
Message:

Made SpaceWizards.HttpListener compilable against .NET 4.8 with preprocessor define UNITY_NETFRAMEWORK

Location:
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable ConditionIsAlwaysTrueOrFalse
     5#pragma warning disable CS8601
     6#pragma warning disable CS8618
    37
    48using System;
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpWebSocket.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable UnusedMember.Local
     5#pragma warning disable CS0162
     6#pragma warning disable CS8602
    37
    48using System;
     
    2630
    2731            // SHA1 used only for hashing purposes, not for crypto. Check here for FIPS compat.
     32#if UNITY_NETFRAMEWORK
     33            SHA1 sha1 = SHA1.Create();
     34            byte[] hash = sha1.ComputeHash(toHash);
     35#else
    2836            byte[] hash = SHA1.HashData(toHash);
     37#endif
    2938            return Convert.ToBase64String(hash);
    3039        }
    3140
     41#if UNITY_NETFRAMEWORK
     42        private static readonly char[] protocolsSplitChars = new []{','};
     43#endif
     44       
    3245        // return value here signifies if a Sec-WebSocket-Protocol header should be returned by the server.
    3346        internal static bool ProcessWebSocketProtocolHeader(string? clientSecWebSocketProtocol,
     
    6073            // and the server has specified exactly one protocol
    6174
     75#if UNITY_NETFRAMEWORK
     76            string[] requestProtocols = clientSecWebSocketProtocol.Split(protocolsSplitChars, StringSplitOptions.RemoveEmptyEntries);
     77#else
    6278            string[] requestProtocols = clientSecWebSocketProtocol.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
     79#endif
    6380            acceptProtocol = subProtocol;
    6481
     
    6885            {
    6986                string currentRequestProtocol = requestProtocols[i];
     87#if UNITY_NETFRAMEWORK
     88                currentRequestProtocol = currentRequestProtocol.Trim ();
     89                if (currentRequestProtocol.Length == 0) {
     90                    continue;
     91                }
     92#endif
    7093                if (string.Equals(acceptProtocol, currentRequestProtocol, StringComparison.OrdinalIgnoreCase))
    7194                {
  • binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/WebSocketValidate.cs

    r376 r377  
    11// Licensed to the .NET Foundation under one or more agreements.
    22// The .NET Foundation licenses this file to you under the MIT license.
     3
     4// ReSharper disable PartialTypeWithSinglePart
     5// ReSharper disable ConditionIsAlwaysTrueOrFalse
    36
    47using System.Diagnostics;
Note: See TracChangeset for help on using the changeset viewer.