Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-sonarscanner": {
"version": "11.0.0",
"version": "11.2.1",
"commands": [
"dotnet-sonarscanner"
]
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

Expand All @@ -36,7 +36,7 @@ jobs:
sudo apt-get install -y libmsquic

- name: Download .NET SDK
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0

Expand Down Expand Up @@ -110,24 +110,33 @@ jobs:

- os:
name: 🍎
runs-on: macos-15-intel
runs-on: macos-26-intel
arch: x64
runtime: osx-x64
platform: macos/amd64

- os:
name: 🍎
runs-on: macos-15
runs-on: macos-26
arch: arm64
runtime: osx-arm64
platform: macos/arm64

steps:
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Harden macOS x64 environment

if: matrix.os.runs-on == 'macos-26-intel'
run: |
sudo rm -rf /opt/homebrew || true
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export DYLD_LIBRARY_PATH=""
export DYLD_FALLBACK_LIBRARY_PATH=""

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
if: matrix.os.runs-on != 'linux-arm32'
with:
dotnet-version: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0

- name: Setup NuGet CLI
uses: NuGet/setup-nuget@v2
uses: NuGet/setup-nuget@v4

- name: Restore dependencies
run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion Adapters/AspNetCore/GenHTTP.Adapters.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="10.0.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<ItemGroup>

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.203" PrivateAssets="All" />

</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Engine/Internal/GenHTTP.Engine.Internal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

<ProjectReference Include="..\..\Modules\IO\GenHTTP.Modules.IO.csproj" />

<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="10.0.7" />

<PackageReference Include="System.IO.Pipelines" Version="10.0.5" />
<PackageReference Include="System.IO.Pipelines" Version="10.0.7" />

</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Modules/Archives/GenHTTP.Modules.Archives.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ProjectReference Include="..\IO\GenHTTP.Modules.IO.csproj" />

<PackageReference Include="SharpCompress" Version="0.47.3" />
<PackageReference Include="SharpCompress" Version="0.47.4" />

</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Modules/Caching/GenHTTP.Modules.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<PackageReference Include="AsyncKeyedLock" Version="8.0.2" />

<PackageReference Include="System.Text.Json" Version="10.0.5" />
<PackageReference Include="System.Text.Json" Version="10.0.7" />

</ItemGroup>

Expand Down
37 changes: 23 additions & 14 deletions Modules/Compression/Providers/CompressionConcern.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO.Compression;
using System.Buffers;
using System.IO.Compression;

using GenHTTP.Api.Content;
using GenHTTP.Api.Content.IO;
Expand Down Expand Up @@ -131,31 +132,39 @@ private bool ShouldCompressBySize(IResponse response)

return MinimumSize is null || contentLength is null || contentLength >= MinimumSize;
}

private static readonly SearchValues<char> Delimiters = SearchValues.Create([',', ';']);

private static HashSet<string> ParseSupported(ReadOnlySpan<char> acceptHeader)
{
var result = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

var start = 0;

while (start <= acceptHeader.Length)
while (!acceptHeader.IsEmpty)
{
var comma = acceptHeader[start..].IndexOf(',');
var end = comma >= 0 ? start + comma : acceptHeader.Length;

var part = acceptHeader.Slice(start, end - start).Trim();
var delimIdx = acceptHeader.IndexOfAny(Delimiters);

if (!part.IsEmpty)
ReadOnlySpan<char> token;
if (delimIdx < 0)
{
result.Add(part.ToString());
token = acceptHeader.Trim();
acceptHeader = default;
}

if (comma < 0)
else if (acceptHeader[delimIdx] == ',')
{
token = acceptHeader[..delimIdx].Trim();
acceptHeader = acceptHeader[(delimIdx + 1)..];
}
else
{
break;
token = acceptHeader[..delimIdx].TrimEnd();
var commaIdx = acceptHeader[delimIdx..].IndexOf(',');
acceptHeader = commaIdx >= 0
? acceptHeader[(delimIdx + commaIdx + 1)..]
: default;
}

start = end + 1;
if (!token.IsEmpty)
result.Add(token.ToString());
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Conversion/GenHTTP.Modules.Conversion.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ProjectReference Include="..\IO\GenHTTP.Modules.IO.csproj" />

<PackageReference Include="YamlDotNet" Version="16.3.0" />
<PackageReference Include="YamlDotNet" Version="17.0.1" />

</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.7" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Modules/OpenApi/GenHTTP.Modules.OpenApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

<ProjectReference Include="..\Reflection\GenHTTP.Modules.Reflection.csproj" />

<PackageReference Include="NSwag.Core" Version="14.6.3" />
<PackageReference Include="NSwag.Core" Version="14.7.1" />

<PackageReference Include="NSwag.Core.Yaml" Version="14.6.3" />
<PackageReference Include="NSwag.Core.Yaml" Version="14.7.1" />

<PackageReference Include="NSwag.Generation" Version="14.6.3" />
<PackageReference Include="NSwag.Generation" Version="14.7.1" />

</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Modules/ReverseProxy/GenHTTP.Modules.ReverseProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ProjectReference Include="..\Websockets\GenHTTP.Modules.Websockets.csproj" />

<PackageReference Include="System.IO.Pipelines" Version="10.0.5" />
<PackageReference Include="System.IO.Pipelines" Version="10.0.7" />

</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Modules/Websockets/GenHTTP.Modules.Websockets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>

<PackageReference Include="System.IO.Pipelines" Version="10.0.5" />
<PackageReference Include="System.IO.Pipelines" Version="10.0.7" />

<ProjectReference Include="..\..\API\GenHTTP.Api.csproj"/>

Expand Down
10 changes: 5 additions & 5 deletions Testing/Acceptance/GenHTTP.Testing.Acceptance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@

<ItemGroup>

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />

<PackageReference Include="Microsoft.OpenApi" Version="3.5.0" />
<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.5.0" />
<PackageReference Include="Microsoft.OpenApi" Version="3.5.2" />
<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.5.2" />

<PackageReference Include="MSTest" Version="4.1.0" />
<PackageReference Include="MSTest" Version="4.2.1" />

<PackageReference Include="NSubstitute" Version="5.3.0" />

<PackageReference Include="coverlet.collector" Version="8.0.1">
<PackageReference Include="coverlet.collector" Version="10.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
16 changes: 15 additions & 1 deletion Testing/Acceptance/Modules/Compression/CompressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task TestCompression(TestEngine engine)

Assert.AreEqual("zstd", response.Content.Headers.ContentEncoding.First());
}

/// <summary>
/// As a browser, I expect only supported compression algorithms to be used
/// to generate my response.
Expand Down Expand Up @@ -378,6 +378,20 @@ public async Task TestCompressionThreshold_Disabled_AllContentCompressed(TestEng

await runner.DisposeAsync();
}

[TestMethod]
[MultiEngineTest]
public async Task TestWeights(TestEngine engine)
{
await using var runner = await TestHost.RunAsync(CreateLargeContentHandler().Build(), engine: engine);

var request = runner.GetRequest();
request.Headers.Add("Accept-Encoding", "br;q=1, gzip;q=0.8");

using var response = await runner.GetResponseAsync(request);

Assert.AreEqual("br", response.Content.Headers.ContentEncoding.First());
}

/// <summary>
/// Helper class to create content with unknown length (null)
Expand Down
Loading