Skip to content

Commit 2ac023c

Browse files
authored
process more TLS frames at one when available (#50815)
* process more TLS frames when available * add SslStream.Implementation.cs * remove extra comment * add back DefaultRequestHeaders_SentUnparsed * feedback from review * fix winhttp * fix linker test * feedback from review * feedback from review * feedback from review * make EnsureFullTlsFrame async * feedback from review
1 parent 5c2ff17 commit 2ac023c

File tree

17 files changed

+239
-411
lines changed

17 files changed

+239
-411
lines changed

src/libraries/Common/src/Interop/Android/System.Security.Cryptography.Native.Android/Interop.Ssl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private static unsafe extern PAL_SSLStreamStatus SSLStreamRead(
166166
out int bytesRead);
167167
internal static unsafe PAL_SSLStreamStatus SSLStreamRead(
168168
SafeSslHandle sslHandle,
169-
Span<byte> buffer,
169+
ReadOnlySpan<byte> buffer,
170170
out int bytesRead)
171171
{
172172
fixed (byte* bufferPtr = buffer)

src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
using System.Buffers;
65
using System.Collections.Generic;
76
using System.Diagnostics;
87
using System.Globalization;
98
using System.IO;
10-
using System.Net.Http;
119
using System.Net.Security;
1210
using System.Runtime.CompilerServices;
1311
using System.Runtime.InteropServices;
1412
using System.Security.Authentication;
1513
using System.Security.Authentication.ExtendedProtection;
1614
using System.Security.Cryptography;
17-
using System.Security.Cryptography.X509Certificates;
1815
using Microsoft.Win32.SafeHandles;
1916

2017
internal static partial class Interop

src/libraries/Common/tests/System/Net/Http/SchSendAuxRecordHttpTest.cs

Lines changed: 0 additions & 127 deletions
This file was deleted.

src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/PlatformHandlerTest.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ public sealed class PlatformHandler_HttpClientHandler_Proxy_Test : HttpClientHan
135135
public PlatformHandler_HttpClientHandler_Proxy_Test(ITestOutputHelper output) : base(output) { }
136136
}
137137

138-
public sealed class PlatformHandler_SchSendAuxRecordHttpTest : SchSendAuxRecordHttpTest
139-
{
140-
public PlatformHandler_SchSendAuxRecordHttpTest(ITestOutputHelper output) : base(output) { }
141-
}
142-
143138
public sealed class PlatformHandler_HttpClientHandlerTest : HttpClientHandlerTest
144139
{
145140
public PlatformHandler_HttpClientHandlerTest(ITestOutputHelper output) : base(output) { }
@@ -299,13 +294,6 @@ public sealed class PlatformHandler_HttpClientHandler_Proxy_Http2_Test : HttpCli
299294
public PlatformHandler_HttpClientHandler_Proxy_Http2_Test(ITestOutputHelper output) : base(output) { }
300295
}
301296

302-
public sealed class PlatformHandler_SchSendAuxRecordHttp_Http2_Test : SchSendAuxRecordHttpTest
303-
{
304-
protected override Version UseVersion => HttpVersion20.Value;
305-
306-
public PlatformHandler_SchSendAuxRecordHttp_Http2_Test(ITestOutputHelper output) : base(output) { }
307-
}
308-
309297
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsWindows10Version1607OrGreater))]
310298
public sealed class PlatformHandler_HttpClientHandler_Http2_Test : HttpClientHandlerTest
311299
{

src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/System.Net.Http.WinHttpHandler.Functional.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@
127127
Link="Common\System\Net\Http\RepeatedFlushContent.cs" />
128128
<Compile Include="$(CommonTestPath)System\Net\Http\ResponseStreamTest.cs"
129129
Link="Common\System\Net\Http\ResponseStreamTest.cs" />
130-
<Compile Include="$(CommonTestPath)System\Net\Http\SchSendAuxRecordHttpTest.cs"
131-
Link="Common\System\Net\Http\SchSendAuxRecordHttpTest.cs" />
132130
<Compile Include="$(CommonTestPath)System\Net\Http\SyncBlockingContent.cs"
133131
Link="Common\System\Net\Http\SyncBlockingContent.cs" />
134132
<Compile Include="$(CommonTestPath)System\Net\Http\ThrowingContent.cs"

src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,6 @@ public async Task Http2GetAsync_TrailingHeaders_NoData_EmptyResponseObserved()
985985
}
986986
}
987987

988-
public sealed class SocketsHttpHandler_SchSendAuxRecordHttpTest : SchSendAuxRecordHttpTest
989-
{
990-
public SocketsHttpHandler_SchSendAuxRecordHttpTest(ITestOutputHelper output) : base(output) { }
991-
}
992-
993988
public sealed class SocketsHttpHandler_HttpClientHandlerTest : HttpClientHandlerTest
994989
{
995990
public SocketsHttpHandler_HttpClientHandlerTest(ITestOutputHelper output) : base(output) { }

src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@
174174
Link="Common\System\Net\Http\RepeatedFlushContent.cs" />
175175
<Compile Include="$(CommonTestPath)System\Net\Http\ResponseStreamTest.cs"
176176
Link="Common\System\Net\Http\ResponseStreamTest.cs" />
177-
<Compile Include="$(CommonTestPath)System\Net\Http\SchSendAuxRecordHttpTest.cs"
178-
Link="Common\System\Net\Http\SchSendAuxRecordHttpTest.cs" />
179177
<Compile Include="SyncHttpHandlerTest.cs" />
180178
<Compile Include="TelemetryTest.cs" />
181179
<Compile Include="StreamContentTest.cs" />

src/libraries/System.Net.Security/src/System/Net/Logging/NetEventSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal sealed partial class NetEventSource : EventSource
1313
/// <param name="buffer">The buffer to be logged.</param>
1414
/// <param name="memberName">The calling member.</param>
1515
[NonEvent]
16-
public static void DumpBuffer(object thisOrContextObject, ReadOnlyMemory<byte> buffer, [CallerMemberName] string? memberName = null)
16+
public static void DumpBuffer(object thisOrContextObject, ReadOnlySpan<byte> buffer, [CallerMemberName] string? memberName = null)
1717
{
1818
if (Log.IsEnabled())
1919
{

src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ is non-zero.
879879
--*/
880880
internal SecurityStatusPal Encrypt(ReadOnlyMemory<byte> buffer, ref byte[] output, out int resultSize)
881881
{
882-
if (NetEventSource.Log.IsEnabled()) NetEventSource.DumpBuffer(this, buffer);
882+
if (NetEventSource.Log.IsEnabled()) NetEventSource.DumpBuffer(this, buffer.Span);
883883

884884
byte[] writeBuffer = output;
885885

@@ -903,24 +903,12 @@ internal SecurityStatusPal Encrypt(ReadOnlyMemory<byte> buffer, ref byte[] outpu
903903
return secStatus;
904904
}
905905

906-
internal SecurityStatusPal Decrypt(byte[]? payload, ref int offset, ref int count)
906+
internal SecurityStatusPal Decrypt(Span<byte> buffer, out int outputOffset, out int outputCount)
907907
{
908-
if ((uint)offset > (uint)(payload == null ? 0 : payload.Length))
909-
{
910-
Debug.Fail("Argument 'offset' out of range.");
911-
throw new ArgumentOutOfRangeException(nameof(offset));
912-
}
913-
914-
if ((uint)count > (uint)(payload == null ? 0 : payload.Length - offset))
915-
{
916-
Debug.Fail("Argument 'count' out of range.");
917-
throw new ArgumentOutOfRangeException(nameof(count));
918-
}
919-
920-
SecurityStatusPal status = SslStreamPal.DecryptMessage(_securityContext!, payload!, ref offset, ref count);
908+
SecurityStatusPal status = SslStreamPal.DecryptMessage(_securityContext!, buffer, out outputOffset, out outputCount);
921909
if (NetEventSource.Log.IsEnabled() && status.ErrorCode == SecurityStatusPalErrorCode.OK)
922910
{
923-
NetEventSource.DumpBuffer(this, payload!, offset, count);
911+
NetEventSource.DumpBuffer(this, buffer.Slice(outputOffset, outputCount));
924912
}
925913

926914
return status;

0 commit comments

Comments
 (0)