Skip to content

Commit d9831c6

Browse files
Merge branch 'main' into dependabot/nuget/Testing/Acceptance/multi-5812bfa265
2 parents dae89e3 + 27fac58 commit d9831c6

File tree

26 files changed

+467
-323
lines changed

26 files changed

+467
-323
lines changed

.github/workflows/build.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
11+
build:
12+
13+
name: Test & Coverage
14+
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
20+
DOTNET_ROLL_FORWARD: Major
21+
22+
steps:
23+
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Install msquic
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install -y libmsquic
33+
34+
- name: Download .NET SDK
35+
uses: actions/setup-dotnet@v4
36+
with:
37+
dotnet-version: 9.0
38+
39+
- name: Restore tools
40+
run: dotnet tool restore
41+
42+
- name: Begin scan
43+
if: env.SONAR_TOKEN != null && env.SONAR_TOKEN != ''
44+
run: dotnet sonarscanner begin /k:"GenHTTP" /d:sonar.token="$SONAR_TOKEN" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.exclusions="**/bin/**/*,**/obj/**/*,**/Playground/**/*,**/*.css,**/*.js,**/*.html" /o:"kaliumhexacyanoferrat" /k:"GenHTTP" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.branch.name="${GITHUB_REF##*/}" /d:sonar.dotnet.excludeTestProjects=true
45+
46+
- name: Build project
47+
run: dotnet build GenHTTP.slnx -c Release
48+
49+
- name: Test project
50+
run: dotnet test GenHTTP.slnx --no-build --collect:"XPlat Code Coverage" -c Release -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
51+
52+
- name: End scan
53+
if: env.SONAR_TOKEN != null && env.SONAR_TOKEN != ''
54+
run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
55+
56+
verify:
57+
58+
name: ${{ matrix.os.name }} ${{ matrix.arch }}
59+
60+
needs: build
61+
62+
runs-on: ${{ matrix.os.runs-on }}
63+
64+
env:
65+
TEST_ENGINE: Internal
66+
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
include:
71+
72+
- os:
73+
name: 🐧
74+
runs-on: ubuntu-latest
75+
arch: x64
76+
runtime: linux-x64
77+
platform: linux/amd64
78+
79+
- os:
80+
name: 🐧
81+
runs-on: linux-arm32
82+
arch: arm32
83+
runtime: linux-arm
84+
platform: linux/arm/v7
85+
86+
- os:
87+
name: 🐧
88+
runs-on: ubuntu-22.04-arm
89+
arch: arm64
90+
runtime: linux-arm64
91+
platform: linux/arm64/v8
92+
93+
- os:
94+
name: 🪟
95+
runs-on: windows-latest
96+
arch: x64
97+
runtime: win-x64
98+
platform: windows/amd64
99+
100+
- os:
101+
name: 🪟
102+
runs-on: windows-latest
103+
arch: arm64
104+
runtime: win-arm64
105+
platform: windows/arm64
106+
107+
- os:
108+
name: 🍎
109+
runs-on: macos-15-intel
110+
arch: x64
111+
runtime: osx-x64
112+
platform: macos/amd64
113+
114+
- os:
115+
name: 🍎
116+
runs-on: macos-15
117+
arch: arm64
118+
runtime: osx-arm64
119+
platform: macos/arm64
120+
121+
steps:
122+
- name: Checkout source
123+
uses: actions/checkout@v4
124+
125+
- name: Setup .NET SDK
126+
uses: actions/setup-dotnet@v4
127+
if: matrix.os.runs-on != 'linux-arm32'
128+
with:
129+
dotnet-version: |
130+
8.0
131+
9.0
132+
133+
- name: Build & Test (${{ matrix.runtime }})
134+
run: dotnet test Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj -c Release

.github/workflows/ci.yml

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

Adapters/AspNetCore/Mapping/Bridge.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using GenHTTP.Adapters.AspNetCore.Server;
22
using GenHTTP.Adapters.AspNetCore.Types;
3+
34
using GenHTTP.Api.Content;
45
using GenHTTP.Api.Infrastructure;
56
using GenHTTP.Api.Protocol;
7+
68
using Microsoft.AspNetCore.Http;
79

810
namespace GenHTTP.Adapters.AspNetCore.Mapping;
@@ -12,7 +14,7 @@ public static class Bridge
1214

1315
public static async ValueTask MapAsync(HttpContext context, IHandler handler, IServer? server = null, IServerCompanion? companion = null, string? registeredPath = null)
1416
{
15-
var actualServer = server ?? new ImplicitServer(handler, companion);
17+
var actualServer = server ?? new ImplicitServer(context, handler, companion);
1618

1719
try
1820
{

Adapters/AspNetCore/Server/EmptyEndpoints.cs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using GenHTTP.Api.Infrastructure;
2+
using Microsoft.AspNetCore.Http;
3+
4+
namespace GenHTTP.Adapters.AspNetCore.Server;
5+
6+
public class EndpointCollection : List<IEndPoint>, IEndPointCollection
7+
{
8+
9+
public EndpointCollection(HttpContext context)
10+
{
11+
Add(new ImplicitEndpoint(context));
12+
}
13+
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Net;
2+
3+
using GenHTTP.Api.Infrastructure;
4+
5+
using Microsoft.AspNetCore.Http;
6+
7+
namespace GenHTTP.Adapters.AspNetCore.Server;
8+
9+
public class ImplicitEndpoint(HttpContext context) : IEndPoint
10+
{
11+
12+
public IPAddress? Address => context.Connection.LocalIpAddress;
13+
14+
public ushort Port => (ushort)context.Connection.LocalPort;
15+
16+
public bool Secure => context.Request.IsHttps;
17+
18+
public void Dispose()
19+
{
20+
// nop
21+
}
22+
23+
}

Adapters/AspNetCore/Server/ImplicitServer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using GenHTTP.Api.Content;
44
using GenHTTP.Api.Infrastructure;
55

6+
using Microsoft.AspNetCore.Http;
7+
68
namespace GenHTTP.Adapters.AspNetCore.Server;
79

810
public sealed class ImplicitServer : IServer
@@ -33,12 +35,12 @@ public bool Development
3335

3436
#region Initialization
3537

36-
public ImplicitServer(IHandler handler, IServerCompanion? companion)
38+
public ImplicitServer(HttpContext context, IHandler handler, IServerCompanion? companion)
3739
{
3840
Handler = handler;
3941
Companion = companion;
4042

41-
EndPoints = new EmptyEndpoints();
43+
EndPoints = new EndpointCollection(context);
4244

4345
Running = true;
4446
}

Adapters/AspNetCore/Types/Request.cs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,27 @@ namespace GenHTTP.Adapters.AspNetCore.Types;
1212

1313
public sealed class Request : IRequest
1414
{
15-
private RequestProperties? _Properties;
15+
private RequestProperties? _properties;
1616

17-
private Query? _Query;
17+
private Query? _query;
1818

19-
private Cookies? _Cookies;
19+
private Cookies? _cookies;
2020

21-
private readonly ForwardingCollection _Forwardings = new();
21+
private readonly ForwardingCollection _forwardings = new();
2222

23-
private Headers? _Headers;
24-
25-
private readonly IEndPoint? _EndPoint;
23+
private Headers? _headers;
2624

2725
#region Get-/Setters
2826

2927
public IRequestProperties Properties
3028
{
31-
get { return _Properties ??= new RequestProperties(); }
29+
get { return _properties ??= new RequestProperties(); }
3230
}
3331

3432
public IServer Server { get; }
3533

36-
public IEndPoint EndPoint => _EndPoint ?? throw new InvalidOperationException("EndPoint is not available as it is managed by ASP.NET Core");
37-
34+
public IEndPoint EndPoint { get; }
35+
3836
public IClientConnection Client { get; }
3937

4038
public IClientConnection LocalClient { get; }
@@ -55,19 +53,19 @@ public IRequestProperties Properties
5553

5654
public IRequestQuery Query
5755
{
58-
get { return _Query ??= new Query(Context); }
56+
get { return _query ??= new Query(Context); }
5957
}
6058

6159
public ICookieCollection Cookies
6260
{
63-
get { return _Cookies ??= new Cookies(Context); }
61+
get { return _cookies ??= new Cookies(Context); }
6462
}
6563

66-
public IForwardingCollection Forwardings => _Forwardings;
64+
public IForwardingCollection Forwardings => _forwardings;
6765

6866
public IHeaderCollection Headers
6967
{
70-
get { return _Headers ??= new Headers(Context); }
68+
get { return _headers ??= new Headers(Context); }
7169
}
7270

7371
public Stream Content => Context.BodyReader.AsStream(true);
@@ -101,19 +99,19 @@ public Request(IServer server, HttpContext context)
10199
{
102100
foreach (var entry in forwardings)
103101
{
104-
if (entry != null) _Forwardings.Add(entry);
102+
if (entry != null) _forwardings.Add(entry);
105103
}
106104
}
107105
else
108106
{
109-
_Forwardings.TryAddLegacy(Headers);
107+
_forwardings.TryAddLegacy(Headers);
110108
}
111109

112110
LocalClient = new ClientConnection(context.Connection, context.Request);
113111

114-
Client = _Forwardings.DetermineClient(context.Connection.ClientCertificate) ?? LocalClient;
112+
Client = _forwardings.DetermineClient(context.Connection.ClientCertificate) ?? LocalClient;
115113

116-
_EndPoint = Server.EndPoints.FirstOrDefault(e => e.Port == context.Connection.LocalPort);
114+
EndPoint = Server.EndPoints.First(e => e.Port == context.Connection.LocalPort);
117115
}
118116

119117
#endregion
@@ -128,15 +126,15 @@ public Request(IServer server, HttpContext context)
128126

129127
#region Lifecycle
130128

131-
private bool _Disposed;
129+
private bool _disposed;
132130

133131
public void Dispose()
134132
{
135-
if (!_Disposed)
133+
if (!_disposed)
136134
{
137-
_Properties?.Dispose();
135+
_properties?.Dispose();
138136

139-
_Disposed = true;
137+
_disposed = true;
140138
}
141139
}
142140

Engine/Internal/Infrastructure/Endpoints/EndPoint.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using GenHTTP.Api.Infrastructure;
66

77
using GenHTTP.Engine.Internal.Protocol;
8+
using GenHTTP.Engine.Internal.Utilities;
89
using GenHTTP.Engine.Shared.Infrastructure;
910

1011
namespace GenHTTP.Engine.Internal.Infrastructure.Endpoints;
@@ -98,7 +99,7 @@ private void Handle(Socket client)
9899

99100
protected abstract ValueTask Accept(Socket client);
100101

101-
protected ValueTask Handle(Socket client, Stream inputStream, X509Certificate? clientCertificate = null)
102+
protected ValueTask Handle(Socket client, PoolBufferedStream inputStream, X509Certificate? clientCertificate = null)
102103
{
103104
client.NoDelay = true;
104105

0 commit comments

Comments
 (0)