Skip to content

Commit a59ea0e

Browse files
committed
TEMP
1 parent 6bfe8bd commit a59ea0e

270 files changed

Lines changed: 21390 additions & 2359 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Servus.Akka.TestKit.Tests/TestConnectionStageExtensionsSpec.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public async Task PushData_bytes_should_deliver_TransportData_inbound()
2626
.Build();
2727

2828
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
29-
{ Host = "localhost", Port = 80 }))
29+
{ Host = "localhost", Port = 80 }))
3030
.Via(stage.AsFlow())
3131
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
3232
{
@@ -59,7 +59,7 @@ public async Task PushData_string_should_deliver_TransportData_inbound()
5959
.Build();
6060

6161
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
62-
{ Host = "localhost", Port = 80 }))
62+
{ Host = "localhost", Port = 80 }))
6363
.Via(stage.AsFlow())
6464
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
6565
{
@@ -91,7 +91,7 @@ public async Task PushStreamOpened_should_deliver_StreamOpened_inbound()
9191
.Build();
9292

9393
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
94-
{ Host = "localhost", Port = 80 }))
94+
{ Host = "localhost", Port = 80 }))
9595
.Via(stage.AsFlow())
9696
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
9797
{
@@ -125,7 +125,7 @@ public async Task PushMultiplexedData_should_deliver_MultiplexedData_inbound()
125125
.Build();
126126

127127
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
128-
{ Host = "localhost", Port = 80 }))
128+
{ Host = "localhost", Port = 80 }))
129129
.Via(stage.AsFlow())
130130
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
131131
{
@@ -159,7 +159,7 @@ public async Task SimulateInboundStream_should_push_full_lifecycle()
159159
.Build();
160160

161161
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
162-
{ Host = "localhost", Port = 80 }))
162+
{ Host = "localhost", Port = 80 }))
163163
.Via(stage.AsFlow())
164164
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
165165
{
@@ -196,7 +196,7 @@ public async Task PushDisconnected_should_push_TransportDisconnected()
196196
.Build();
197197

198198
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
199-
{ Host = "localhost", Port = 80 }))
199+
{ Host = "localhost", Port = 80 }))
200200
.Via(stage.AsFlow())
201201
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
202202
{
@@ -268,7 +268,7 @@ public async Task PushStreamClosed_should_deliver_StreamClosed_inbound()
268268
.Build();
269269

270270
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
271-
{ Host = "localhost", Port = 80 }))
271+
{ Host = "localhost", Port = 80 }))
272272
.Via(stage.AsFlow())
273273
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
274274
{
@@ -302,7 +302,7 @@ public async Task PushConnectionMigration_should_deliver_ConnectionMigrationDete
302302
.Build();
303303

304304
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
305-
{ Host = "localhost", Port = 80 }))
305+
{ Host = "localhost", Port = 80 }))
306306
.Via(stage.AsFlow())
307307
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
308308
{
@@ -358,7 +358,7 @@ public async Task PushStreamReadCompleted_should_deliver_StreamReadCompleted_inb
358358
.Build();
359359

360360
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
361-
{ Host = "localhost", Port = 80 }))
361+
{ Host = "localhost", Port = 80 }))
362362
.Via(stage.AsFlow())
363363
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
364364
{
@@ -391,7 +391,7 @@ public async Task PushStreamClosed_with_error_reason_should_deliver_error()
391391
.Build();
392392

393393
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
394-
{ Host = "localhost", Port = 80 }))
394+
{ Host = "localhost", Port = 80 }))
395395
.Via(stage.AsFlow())
396396
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
397397
{
@@ -425,7 +425,7 @@ public async Task PushDisconnected_default_reason_should_be_graceful()
425425
.Build();
426426

427427
_ = Source.Single<ITransportOutbound>(new ConnectTransport(new TcpTransportOptions
428-
{ Host = "localhost", Port = 80 }))
428+
{ Host = "localhost", Port = 80 }))
429429
.Via(stage.AsFlow())
430430
.RunWith(Sink.ForEach<ITransportInbound>(msg =>
431431
{
@@ -445,4 +445,4 @@ public async Task PushDisconnected_default_reason_should_be_graceful()
445445
var disconnected = Assert.IsType<TransportDisconnected>(inbound[1]);
446446
Assert.Equal(DisconnectReason.Graceful, disconnected.Reason);
447447
}
448-
}
448+
}

src/TurboHTTP.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TurboHTTP.IntegrationTests.Container")]
66
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TurboHTTP.IntegrationTests.Kestrel")]
77
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TurboHTTP.MicroBenchmarks")]
8+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TurboHTTP.Server")]
9+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TurboHTTP.Server.Tests")]
810
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TurboHTTP.Tests")]
911
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TurboHTTP.Tests.Shared")]
1012
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName=".NET 10.0")]
@@ -49,7 +51,7 @@ namespace TurboHTTP
4951
public int InitialConnectionWindowSize { get; set; }
5052
public int InitialStreamWindowSize { get; set; }
5153
public System.TimeSpan KeepAlivePingDelay { get; set; }
52-
public TurboHTTP.HttpKeepAlivePingPolicy KeepAlivePingPolicy { get; set; }
54+
public System.Net.Http.HttpKeepAlivePingPolicy KeepAlivePingPolicy { get; set; }
5355
public System.TimeSpan KeepAlivePingTimeout { get; set; }
5456
public int MaxConcurrentStreams { get; set; }
5557
public int MaxConnectionsPerServer { get; set; }
@@ -70,11 +72,6 @@ namespace TurboHTTP
7072
public int QpackBlockedStreams { get; set; }
7173
public int QpackMaxTableCapacity { get; set; }
7274
}
73-
public enum HttpKeepAlivePingPolicy
74-
{
75-
WithActiveRequests = 0,
76-
Always = 1,
77-
}
7875
public interface ITurboHttpClient : System.IDisposable
7976
{
8077
System.Uri? BaseAddress { get; set; }
@@ -117,6 +114,7 @@ namespace TurboHTTP
117114
public System.Net.ICredentials? Credentials { get; set; }
118115
public bool DangerousAcceptAnyServerCertificate { get; set; }
119116
public System.Net.ICredentials? DefaultProxyCredentials { get; set; }
117+
public System.Net.Security.RemoteCertificateValidationCallback? EffectiveServerCertificateValidationCallback { get; }
120118
public System.Security.Authentication.SslProtocols EnabledSslProtocols { get; set; }
121119
public TurboHTTP.Http1Options Http1 { get; init; }
122120
public TurboHTTP.Http2Options Http2 { get; init; }

src/TurboHTTP.AcceptanceTests/H10/ErrorHandlingSpec.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public async Task ErrorHandling_should_cause_exception_on_midresponse_connection
8686
// Content-Length says 10000, but we only send 7 bytes then abort
8787
var raw = "HTTP/1.0 200 OK\r\nContent-Length: 10000\r\n\r\npartial";
8888

89-
var fake = CreateScriptedConnection((_, _) => Encoding.Latin1.GetBytes(raw));
89+
var fake = CreateScriptedConnectionWithClose((_, _) => Encoding.Latin1.GetBytes(raw));
9090
var flow = CreateHttp10Engine().CreateFlow().Join(fake.AsFlow());
9191

9292
var tcs = new TaskCompletionSource<HttpResponseMessage>();

src/TurboHTTP.AcceptanceTests/H10/ResilienceSpec.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task Resilience_should_cause_exception_on_content_length_mismatch()
5757
// Declare Content-Length: 100 but only send 5 bytes
5858
const string raw = "HTTP/1.0 200 OK\r\nContent-Length: 100\r\n\r\nhello";
5959

60-
var fake = CreateScriptedConnection((_, _) => Encoding.Latin1.GetBytes(raw));
60+
var fake = CreateScriptedConnectionWithClose((_, _) => Encoding.Latin1.GetBytes(raw));
6161
var flow = CreateHttp10Engine().CreateFlow().Join(fake.AsFlow());
6262

6363
var tcs = new TaskCompletionSource<HttpResponseMessage>();
@@ -146,7 +146,7 @@ public async Task Resilience_should_detect_truncated_body()
146146
headerBytes.CopyTo(responseBytes, 0);
147147
truncatedBody.CopyTo(responseBytes, headerBytes.Length);
148148

149-
var fake = CreateScriptedConnection((_, _) => responseBytes);
149+
var fake = CreateScriptedConnectionWithClose((_, _) => responseBytes);
150150
var flow = CreateHttp10Engine().CreateFlow().Join(fake.AsFlow());
151151

152152
var tcs = new TaskCompletionSource<HttpResponseMessage>();

src/TurboHTTP.AcceptanceTests/H11/ErrorHandlingSpec.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public async Task ErrorHandling_should_raise_exception_on_mid_response_connectio
9090
// Content-Length says 10000, but we only send 7 bytes then abort
9191
var raw = "HTTP/1.1 200 OK\r\nContent-Length: 10000\r\n\r\npartial";
9292

93-
var fake = CreateScriptedConnection((_, _) => Encoding.Latin1.GetBytes(raw));
93+
var fake = CreateScriptedConnectionWithClose((_, _) => Encoding.Latin1.GetBytes(raw));
9494
var flow = Engine.CreateFlow().Join(fake.AsFlow());
9595

9696
var tcs = new TaskCompletionSource<HttpResponseMessage>();

src/TurboHTTP.AcceptanceTests/H11/ResilienceSpec.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ public async Task Resilience_should_cause_exception_on_content_length_mismatch()
5858
Version = HttpVersion.Version11
5959
};
6060

61-
// Declare Content-Length: 100 but only send 5 bytes
61+
// Declare Content-Length: 100 but only send 5 bytes then close
6262
var raw = "HTTP/1.1 200 OK\r\nContent-Length: 100\r\n\r\nhello";
6363

64-
var fake = CreateScriptedConnection((_, _) => Encoding.Latin1.GetBytes(raw));
64+
var fake = CreateScriptedConnectionWithClose((_, _) => Encoding.Latin1.GetBytes(raw));
6565
var flow = Engine.CreateFlow().Join(fake.AsFlow());
6666

6767
var tcs = new TaskCompletionSource<HttpResponseMessage>();
@@ -150,7 +150,7 @@ public async Task Resilience_should_detect_truncated_body()
150150
headerBytes.CopyTo(responseBytes, 0);
151151
truncatedBody.CopyTo(responseBytes, headerBytes.Length);
152152

153-
var fake = CreateScriptedConnection((_, _) => responseBytes);
153+
var fake = CreateScriptedConnectionWithClose((_, _) => responseBytes);
154154
var flow = Engine.CreateFlow().Join(fake.AsFlow());
155155

156156
var tcs = new TaskCompletionSource<HttpResponseMessage>();

src/TurboHTTP.AcceptanceTests/TLS/ErrorHandlingSpec.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public async Task ErrorHandling_should_raise_exception_on_mid_response_connectio
8989

9090
var raw = "HTTP/1.1 200 OK\r\nContent-Length: 10000\r\n\r\npartial";
9191

92-
var fake = CreateScriptedConnection((_, _) => Encoding.Latin1.GetBytes(raw));
92+
var fake = CreateScriptedConnectionWithClose((_, _) => Encoding.Latin1.GetBytes(raw));
9393
var flow = Engine.CreateFlow().Join(fake.AsFlow());
9494

9595
var tcs = new TaskCompletionSource<HttpResponseMessage>();

src/TurboHTTP.AcceptanceTests/TLS/ResilienceSpec.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task Resilience_should_cause_exception_on_content_length_mismatch_o
6060

6161
var raw = "HTTP/1.1 200 OK\r\nContent-Length: 100\r\n\r\nhello";
6262

63-
var fake = CreateScriptedConnection((_, _) => Encoding.Latin1.GetBytes(raw));
63+
var fake = CreateScriptedConnectionWithClose((_, _) => Encoding.Latin1.GetBytes(raw));
6464
var flow = Engine.CreateFlow().Join(fake.AsFlow());
6565

6666
var tcs = new TaskCompletionSource<HttpResponseMessage>();
@@ -147,7 +147,7 @@ public async Task Resilience_should_detect_truncated_body_over_https()
147147
headerBytes.CopyTo(responseBytes, 0);
148148
truncatedBody.CopyTo(responseBytes, headerBytes.Length);
149149

150-
var fake = CreateScriptedConnection((_, _) => responseBytes);
150+
var fake = CreateScriptedConnectionWithClose((_, _) => responseBytes);
151151
var flow = Engine.CreateFlow().Join(fake.AsFlow());
152152

153153
var tcs = new TaskCompletionSource<HttpResponseMessage>();

src/TurboHTTP.IntegrationTests/H10/TransferSpec.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Net;
22
using System.Text;
3-
using System.Text.Json;
43
using TurboHTTP.IntegrationTests.Shared;
54

65
namespace TurboHTTP.IntegrationTests.H10;
@@ -113,13 +112,12 @@ public async Task Transfer_should_echo_large_post_body()
113112
{
114113
Content = new StringContent(payload, Encoding.UTF8, "text/plain")
115114
};
115+
request.Headers.ConnectionClose = true;
116116

117117
var response = await _helper!.Client.SendAsync(request, ct);
118-
var body = await response.Content.ReadAsStringAsync(ct);
119-
var json = JsonDocument.Parse(body);
120-
121118
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
122-
Assert.Equal(payload, json.RootElement.GetProperty("data").GetString());
119+
var body = await response.Content.ReadAsStringAsync(ct);
120+
Assert.Contains(payload, body);
123121
}
124122

125123
[Fact(Timeout = 15000)]

src/TurboHTTP.MicroBenchmarks/Http11/Http11ChunkedDecoderBenchmark.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using BenchmarkDotNet.Attributes;
2+
using System.Buffers;
23
using TurboHTTP.MicroBenchmarks.Internal;
4+
using TurboHTTP.Protocol;
35
using TurboHTTP.Protocol.Http11;
6+
using TurboHTTP.Tests.Shared;
47

58
namespace TurboHTTP.MicroBenchmarks.Http11;
69

@@ -39,13 +42,27 @@ public void Setup()
3942
public bool DecodeSingleChunk()
4043
{
4144
_decoder.Reset();
42-
return _decoder.TryDecode(_singleChunk, out _);
45+
var decoded = _decoder.TryDecodeHeaders(_singleChunk, out _, out var framing, out _);
46+
if (framing != BodyFraming.None)
47+
{
48+
var (owner, _, _) = _decoder.FeedBody(ReadOnlyMemory<byte>.Empty);
49+
owner?.Dispose();
50+
}
51+
_decoder.Reset();
52+
return decoded;
4353
}
4454

4555
[Benchmark]
4656
public bool Decode20SmallChunks()
4757
{
4858
_decoder.Reset();
49-
return _decoder.TryDecode(_manySmallChunks, out _);
59+
var decoded = _decoder.TryDecodeHeaders(_manySmallChunks, out _, out var framing, out _);
60+
if (framing != BodyFraming.None)
61+
{
62+
var (owner, _, _) = _decoder.FeedBody(ReadOnlyMemory<byte>.Empty);
63+
owner?.Dispose();
64+
}
65+
_decoder.Reset();
66+
return decoded;
5067
}
5168
}

0 commit comments

Comments
 (0)