Changeset 377 for binary-improvements2/SpaceWizards.HttpListener/src/System
- Timestamp:
- Aug 1, 2022, 12:26:44 PM (2 years ago)
- Location:
- binary-improvements2/SpaceWizards.HttpListener/src/System
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/SpaceWizards.HttpListener/src/System/HexConverter.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantCast 3 5 4 6 #nullable disable … … 95 97 } 96 98 99 #if !UNITY_NETFRAMEWORK 97 100 #if ALLOW_PARTIALLY_TRUSTED_CALLERS 98 101 [System.Security.SecuritySafeCriticalAttribute] … … 130 133 #endif 131 134 } 135 #endif 132 136 133 137 [MethodImpl(MethodImplOptions.AggressiveInlining)] -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CaseInsensitiveAscii.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantCast 3 5 4 6 #nullable enable -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/CookieParser.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable NotAccessedField.Local 6 #pragma warning disable CS8603 3 7 4 8 #nullable enable -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpKnownHeaderNames.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable PartialTypeWithSinglePart 3 5 4 6 namespace System.Net -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListener.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable RedundantUnsafeContext 3 6 4 7 using System; … … 55 58 } 56 59 60 #if !UNITY_NETFRAMEWORK 57 61 [DisallowNull] 62 #endif 58 63 public ExtendedProtectionSelector? ExtendedProtectionSelectorDelegate 59 64 { -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerContext.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable RedundantUnsafeContext 3 6 4 7 using System; … … 38 41 } 39 42 43 #if !UNITY_NETFRAMEWORK 40 44 public Task<WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync(string? subProtocol) 41 45 { … … 47 51 return AcceptWebSocketAsync(subProtocol, HttpWebSocket.DefaultReceiveBufferSize, keepAliveInterval); 48 52 } 53 #endif 49 54 } 50 55 } -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerException.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable VirtualMemberCallInConstructor 3 6 4 7 using System; … … 13 16 public class HttpListenerException : Win32Exception 14 17 { 18 #if !UNITY_NETFRAMEWORK 15 19 public HttpListenerException() : base(Marshal.GetLastPInvokeError()) 16 20 { 17 21 if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}"); 18 22 } 19 23 #endif 24 20 25 public HttpListenerException(int errorCode) : base(errorCode) 21 26 { -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerPrefixCollection.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable AssignNullToNotNullAttribute 3 5 4 6 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequest.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable RedundantUnsafeContext 6 // ReSharper disable RedundantToStringCall 7 // ReSharper disable ConditionIsAlwaysTrueOrFalse 3 8 4 9 using System; … … 185 190 _keepAlive = 186 191 header.IndexOf("close", StringComparison.OrdinalIgnoreCase) < 0 || 192 #if UNITY_NETFRAMEWORK 193 header.IndexOf("keep-alive", StringComparison.OrdinalIgnoreCase) >= 0; 194 #else 187 195 header.Contains("keep-alive", StringComparison.OrdinalIgnoreCase); 196 #endif 188 197 } 189 198 } … … 343 352 return null; 344 353 354 #if UNITY_NETFRAMEWORK 355 attrValue = headerValue.Substring(i + 1, j - i - 1).Trim(); 356 #else 345 357 attrValue = headerValue.AsSpan(i + 1, j - i - 1).Trim().ToString(); 358 #endif 346 359 } 347 360 else … … 356 369 return null; 357 370 371 #if UNITY_NETFRAMEWORK 372 attrValue = headerValue.Substring(i, j - i).Trim(); 373 #else 358 374 attrValue = headerValue.AsSpan(i, j - i).Trim().ToString(); 375 #endif 359 376 } 360 377 -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerRequestUriBuilder.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable ConstantNullCoalescingCondition 5 // ReSharper disable RedundantTernaryExpression 6 // ReSharper disable UnusedParameter.Local 7 // ReSharper disable PossibleUnintendedReferenceComparison 8 #pragma warning disable CS8602 9 #pragma warning disable CS8604 3 10 4 11 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpListenerResponse.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable RedundantUnsafeContext 6 // ReSharper disable RedundantExtendsListEntry 7 // ReSharper disable RedundantSuppressNullableWarningExpression 8 // ReSharper disable ConditionIsAlwaysTrueOrFalse 3 9 4 10 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpRequestStream.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantExtendsListEntry 5 // ReSharper disable RedundantSuppressNullableWarningExpression 3 6 4 7 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/HttpResponseStream.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantExtendsListEntry 3 5 4 6 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/LazyAsyncResult.cs
r376 r377 3 3 4 4 #nullable enable 5 // ReSharper disable ConstantConditionalAccessQualifier 6 5 7 using System.Diagnostics; 6 8 using System.Threading; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Logging/NetEventSource.Common.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable RedundantExtendsListEntry 6 // ReSharper disable UnusedMember.Local 7 // ReSharper disable InterpolatedStringExpressionIsNotIFormattable 8 // ReSharper disable ConditionIsAlwaysTrueOrFalse 9 // ReSharper disable PartialMethodWithSinglePart 3 10 4 11 #if DEBUG -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkStream.cs
r376 r377 31 31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 32 // 33 34 // ReSharper disable RedundantUsingDirective 35 // ReSharper disable ConditionIsAlwaysTrueOrFalse 33 36 34 37 using System; … … 368 371 if (st > 0) 369 372 { 373 #if UNITY_NETFRAMEWORK 374 _saved.Append(stString.Substring(0, _saved.Length == 0 ? st - 2 : st)); 375 #else 370 376 _saved.Append(stString.AsSpan(0, _saved.Length == 0 ? st - 2 : st)); 377 #endif 371 378 st = 0; 372 379 if (_saved.Length > 4196) -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ChunkedInputStream.cs
r376 r377 28 28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 31 // ReSharper disable RedundantUsingDirective 30 32 31 33 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpConnection.cs
r376 r377 30 30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 // 32 33 // ReSharper disable RedundantUsingDirective 34 // ReSharper disable PrivateFieldCanBeConvertedToLocalVariable 35 // ReSharper disable RedundantExplicitArrayCreation 36 // ReSharper disable EmptyGeneralCatchClause 37 // ReSharper disable ConditionIsAlwaysTrueOrFalse 38 // ReSharper disable RedundantJumpStatement 39 #pragma warning disable CS8618 32 40 33 41 using System; … … 132 140 } 133 141 142 #if !UNITY_NETFRAMEWORK 134 143 [MemberNotNull(nameof(_memoryStream))] 135 144 [MemberNotNull(nameof(_context))] 145 #endif 136 146 private void Init() 137 147 { -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointListener.cs
r376 r377 30 30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 // 32 33 // ReSharper disable ConditionIsAlwaysTrueOrFalse 34 // ReSharper disable UnusedParameter.Local 32 35 33 36 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpEndPointManager.cs
r376 r377 30 30 // 31 31 32 // ReSharper disable RedundantAssignment 33 #pragma warning disable CS8602 34 32 35 using System; 33 36 using System.Collections; … … 110 113 else 111 114 { 115 #if UNITY_NETFRAMEWORK 116 if (host.Length > 1 && host[0] == '[' && host[host.Length - 1] == ']') 117 host = host.Substring (1, host.Length - 2); 118 #else 112 119 if (host.StartsWith('[') && host.EndsWith(']')) 113 120 host = host[1..^1]; 121 #endif 114 122 115 123 const int NotSupportedErrorCode = 50; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Certificates.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 3 5 4 6 using System.Collections; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListener.Managed.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable RedundantCast 6 // ReSharper disable RedundantUnsafeContext 3 7 4 8 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerContext.Managed.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable RedundantUnsafeContext 6 // ReSharper disable UnusedVariable 7 #pragma warning disable CS8604 3 8 4 9 using System; … … 61 66 string.Compare(header, 0, AuthenticationTypes.Basic, 0, 5, StringComparison.OrdinalIgnoreCase) == 0; 62 67 68 #if UNITY_NETFRAMEWORK 69 internal static bool TryParseBasicAuth(string headerValue, out HttpStatusCode errorCode, out string? username, out string? password) 70 #else 63 71 internal static bool TryParseBasicAuth(string headerValue, out HttpStatusCode errorCode, [NotNullWhen(true)] out string? username, [NotNullWhen(true)] out string? password) 72 #endif 64 73 { 65 74 errorCode = HttpStatusCode.OK; … … 92 101 } 93 102 103 #if !UNITY_NETFRAMEWORK 94 104 public Task<WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync(string? subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval) 95 105 { … … 104 114 return HttpWebSocket.AcceptWebSocketAsyncCore(this, subProtocol, receiveBufferSize, keepAliveInterval, internalBuffer); 105 115 } 116 #endif 106 117 } 107 118 } -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerRequest.Managed.cs
r376 r377 31 31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 32 // 33 34 // ReSharper disable RedundantUsingDirective 35 // ReSharper disable RedundantCast 36 // ReSharper disable RedundantJumpStatement 37 // ReSharper disable ConditionIsAlwaysTrueOrFalse 33 38 34 39 using System; … … 257 262 } 258 263 264 #if UNITY_NETFRAMEWORK 265 string name = header.Substring(0, colon).Trim(); 266 string val = header.Substring(colon + 1).Trim(); 267 #else 259 268 string name = header.AsSpan(0, colon).Trim().ToString(); 260 269 string val = header.AsSpan(colon + 1).Trim().ToString(); 270 #endif 261 271 if (name.Equals("content-length", StringComparison.OrdinalIgnoreCase)) 262 272 { -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerResponse.Managed.cs
r376 r377 29 29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 30 // 31 32 // ReSharper disable RedundantExtendsListEntry 31 33 32 34 using System; … … 288 290 writer.Write(FormatHeaders(_webHeaders)); 289 291 writer.Flush(); 292 #if UNITY_NETFRAMEWORK 293 int preamble = encoding.GetPreamble().Length; 294 #else 290 295 int preamble = encoding.Preamble.Length; 296 #endif 291 297 EnsureResponseStream(); 292 298 -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpListenerTimeoutManager.Managed.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 5 // ReSharper disable UnusedParameter.Local 3 6 4 7 using System; … … 38 41 } 39 42 43 #if !UNITY_NETFRAMEWORK 40 44 public TimeSpan EntityBody 41 45 { … … 84 88 } 85 89 } 90 #endif 86 91 87 92 private void ValidateTimeout(TimeSpan value) -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpRequestStream.Managed.cs
r376 r377 29 29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 30 // 31 32 // ReSharper disable RedundantUsingDirective 33 // ReSharper disable RedundantExtendsListEntry 34 // ReSharper disable RedundantCast 31 35 32 36 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/HttpResponseStream.Managed.cs
r376 r377 29 29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 30 // 31 32 // ReSharper disable RedundantUsingDirective 33 // ReSharper disable RedundantExtendsListEntry 34 // ReSharper disable EmptyGeneralCatchClause 35 #pragma warning disable CS8600 31 36 32 37 using System; … … 152 157 else 153 158 { 154 try 155 { 159 #if !UNITY_NETFRAMEWORK 160 try 161 { 162 #endif 156 163 _stream.Write(buffer, offset, count); 164 #if !UNITY_NETFRAMEWORK 157 165 } 158 166 catch (IOException ex) … … 160 168 throw new HttpListenerException(ex.HResult, ex.Message); 161 169 } 170 #endif 162 171 } 163 172 } … … 168 177 private async Task InternalWriteIgnoreErrorsAsync(byte[] buffer, int offset, int count) 169 178 { 179 #if UNITY_NETFRAMEWORK 180 try { await _stream.WriteAsync(buffer, offset, count).ConfigureAwait(false); } 181 #else 170 182 try { await _stream.WriteAsync(buffer.AsMemory(offset, count)).ConfigureAwait(false); } 183 #endif 171 184 catch { } 172 185 } … … 282 295 return; 283 296 297 #if UNITY_NETFRAMEWORK 298 HttpStreamAsyncResult result = asyncResult as HttpStreamAsyncResult; 299 if (result != null && result._buffer != null && result._count == 0) 300 #else 284 301 if (asyncResult is HttpStreamAsyncResult { _buffer: not null, _count: 0 }) 302 #endif 285 303 return; 286 304 -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerAsyncResult.Managed.cs
r376 r377 31 31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 32 // 33 34 // ReSharper disable RedundantDelegateCreation 35 // ReSharper disable RedundantSuppressNullableWarningExpression 36 // ReSharper disable EmptyGeneralCatchClause 33 37 34 38 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/ListenerPrefix.cs
r376 r377 30 30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 // 32 33 // ReSharper disable RedundantUsingDirective 34 // ReSharper disable NonReadonlyMemberInGetHashCode 32 35 33 36 using System; … … 84 87 85 88 // Equals and GetHashCode are required to detect duplicates in HttpListenerPrefixCollection. 89 #if UNITY_NETFRAMEWORK 90 public override bool Equals(object? o) 91 #else 86 92 public override bool Equals([NotNullWhen(true)] object? o) 93 #endif 87 94 { 88 95 ListenerPrefix? other = o as ListenerPrefix; … … 118 125 _host = uri.Substring(start_host, end_host - start_host); 119 126 root = uri.IndexOf('/', end_host, length - end_host); 127 #if UNITY_NETFRAMEWORK 128 string portPart = uri.Substring (end_host + 1, root - end_host - 1); 129 _port = (ushort)int.Parse (portPart); 130 #else 120 131 _port = (ushort)int.Parse(uri.AsSpan(end_host + 1, root - end_host - 1)); 132 #endif 121 133 _path = uri.Substring(root); 122 134 } -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed/WebSockets/HttpWebSocket.Managed.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 3 5 4 6 using System; … … 13 15 private const string SupportedVersion = "13"; 14 16 17 #if !UNITY_NETFRAMEWORK 15 18 internal static async Task<HttpListenerWebSocketContext> AcceptWebSocketAsyncCore(HttpListenerContext context, 16 19 string? subProtocol, … … 79 82 return webSocketContext; 80 83 } 81 84 #endif 85 82 86 private const bool WebSocketsSupported = true; 83 87 } -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/NetEventSource.HttpListener.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantExtendsListEntry 3 5 4 6 using System.Diagnostics.Tracing; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/ServiceNameStore.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable NotAccessedVariable 5 // ReSharper disable RedundantExplicitArrayCreation 6 #pragma warning disable CS8602 3 7 4 8 using System; … … 246 250 } 247 251 252 #if UNITY_NETFRAMEWORK 253 internal static int FindEndOfHostname(string uriPrefix, int i) 254 #else 248 255 internal static int FindEndOfHostname(ReadOnlySpan<char> uriPrefix, int i) 256 #endif 249 257 { 250 258 int j = i; … … 311 319 } 312 320 } 321 #if UNITY_NETFRAMEWORK 322 else if (hostname.IndexOf('.') < 0) 323 #else 313 324 else if (!hostname.Contains('.')) 325 #endif 314 326 { 315 327 // for a dotless name, try to resolve the FQDN. If the caller doesn't have DNS permission -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebHeaderEncoding.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable RedundantUsingDirective 3 5 4 6 using System.Diagnostics; … … 14 16 internal static class WebHeaderEncoding 15 17 { 18 19 #if !UNITY_NETFRAMEWORK 16 20 internal static unsafe string GetString(byte[] bytes, int byteIndex, int byteCount) 17 21 { … … 53 57 }); 54 58 } 55 59 #endif 60 56 61 internal static int GetByteCount(string myString) => myString.Length; 57 62 -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // 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 3 7 4 8 using System; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/HttpWebSocket.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // 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 3 7 4 8 using System; … … 26 30 27 31 // 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 28 36 byte[] hash = SHA1.HashData(toHash); 37 #endif 29 38 return Convert.ToBase64String(hash); 30 39 } 31 40 41 #if UNITY_NETFRAMEWORK 42 private static readonly char[] protocolsSplitChars = new []{','}; 43 #endif 44 32 45 // return value here signifies if a Sec-WebSocket-Protocol header should be returned by the server. 33 46 internal static bool ProcessWebSocketProtocolHeader(string? clientSecWebSocketProtocol, … … 60 73 // and the server has specified exactly one protocol 61 74 75 #if UNITY_NETFRAMEWORK 76 string[] requestProtocols = clientSecWebSocketProtocol.Split(protocolsSplitChars, StringSplitOptions.RemoveEmptyEntries); 77 #else 62 78 string[] requestProtocols = clientSecWebSocketProtocol.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); 79 #endif 63 80 acceptProtocol = subProtocol; 64 81 … … 68 85 { 69 86 string currentRequestProtocol = requestProtocols[i]; 87 #if UNITY_NETFRAMEWORK 88 currentRequestProtocol = currentRequestProtocol.Trim (); 89 if (currentRequestProtocol.Length == 0) { 90 continue; 91 } 92 #endif 70 93 if (string.Equals(acceptProtocol, currentRequestProtocol, StringComparison.OrdinalIgnoreCase)) 71 94 { -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/WebSockets/WebSocketValidate.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable PartialTypeWithSinglePart 5 // ReSharper disable ConditionIsAlwaysTrueOrFalse 3 6 4 7 using System.Diagnostics; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Windows/CookieExtensions.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 // ReSharper disable UnusedMember.Local 5 #pragma warning disable CS8602 3 6 4 7 using System; 5 8 using System.Diagnostics; 6 9 using System.Reflection; 7 using System.Diagnostics.CodeAnalysis;8 10 using System.Net; 9 11 -
binary-improvements2/SpaceWizards.HttpListener/src/System/StringExtensions.cs
r376 r377 1 1 // Licensed to the .NET Foundation under one or more agreements. 2 2 // The .NET Foundation licenses this file to you under the MIT license. 3 4 #pragma warning disable CS8602 3 5 4 6 using System.Diagnostics; -
binary-improvements2/SpaceWizards.HttpListener/src/System/Threading/Tasks/TaskToApm.cs
r376 r377 11 11 // public int EndFoo(IAsyncResult asyncResult) => 12 12 // TaskToApm.End<int>(asyncResult); 13 14 // ReSharper disable RedundantUsingDirective 15 // ReSharper disable ConvertTypeCheckPatternToNullCheck 16 // ReSharper disable ConditionIsAlwaysTrueOrFalse 17 #pragma warning disable CS8602 18 #pragma warning disable CS8601 19 #pragma warning disable CS8618 13 20 14 21 #nullable enable … … 64 71 65 72 /// <summary>Throws an argument exception for the invalid <paramref name="asyncResult"/>.</summary> 73 #if !UNITY_NETFRAMEWORK 66 74 [DoesNotReturn] 75 #endif 67 76 private static void ThrowArgumentException(IAsyncResult asyncResult) => 68 77 throw (asyncResult is null ?
Note:
See TracChangeset
for help on using the changeset viewer.