- Timestamp:
- Aug 1, 2022, 12:26:44 PM (2 years ago)
- Location:
- binary-improvements2/SpaceWizards.HttpListener/src/System/Net/Managed
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.