Implement Response Compression and Centralize Accept‑Encoding Handling in HTTP Client Configuration #86
Implement Response Compression and Centralize Accept‑Encoding Handling in HTTP Client Configuration #86
Conversation
Removed the acceptEncodings parameter from AddHttpClientWithResilience and related calls, using a static internal list ("br", "gzip") instead. This ensures consistent Accept-Encoding headers and simplifies the API. Updated all usages and removed redundant variables.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Adds Brotli/Gzip response compression to the ASP.NET Core APIs and centralizes outgoing Accept-Encoding + automatic decompression for HttpClient registrations in the DataEngine.
Changes:
- Enabled ASP.NET Core response compression middleware (Brotli + Gzip) in both DataEngine and TestPlugin.
- Added a centralized
AcceptEncodingslist and appliedAccept-Encodingheaders to resilientHttpClientregistrations. - Enabled automatic decompression (Brotli/Gzip) on the primary
HttpClientHandlerfor resilient clients.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
source/AAS.TwinEngine.Plugin.TestPlugin/Program.cs |
Adds response compression services + middleware to the TestPlugin API pipeline. |
source/AAS.TwinEngine.DataEngine/Program.cs |
Adds response compression services + middleware to the DataEngine API pipeline. |
source/AAS.TwinEngine.DataEngine/Infrastructure/Http/Extensions/HttpClientRegistrationExtensions.cs |
Centralizes Accept-Encoding headers and enables automatic decompression for resilient HttpClient registrations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...AAS.TwinEngine.DataEngine/Infrastructure/Http/Extensions/HttpClientRegistrationExtensions.cs
Show resolved
Hide resolved
...AAS.TwinEngine.DataEngine/Infrastructure/Http/Extensions/HttpClientRegistrationExtensions.cs
Outdated
Show resolved
Hide resolved
...AAS.TwinEngine.DataEngine/Infrastructure/Http/Extensions/HttpClientRegistrationExtensions.cs
Outdated
Show resolved
Hide resolved
…aders for HttpClient
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...AAS.TwinEngine.DataEngine/Infrastructure/Http/Extensions/HttpClientRegistrationExtensions.cs
Outdated
Show resolved
Hide resolved
...AAS.TwinEngine.DataEngine/Infrastructure/Http/Extensions/HttpClientRegistrationExtensions.cs
Outdated
Show resolved
Hide resolved
Centralize and encapsulate logic for configuring HTTP client Accept-Encoding headers and decompression methods. Introduce helper methods for setting headers and creating handlers, improving code clarity and maintainability. Remove redundant static fields and streamline decompression method selection using LINQ.
Removed explicit inclusion of "application/problem+json" and "application/problem+xml" from the response compression middleware. The middleware now uses only the default MIME types provided by ResponseCompressionDefaults.MimeTypes.
…/AAS-TwinEngine/AAS.TwinEngine.DataEngine into feature/614-Response-Compression
|
Test & Coverage ReportTest Results Summary
Code CoverageUnit Tests Coverage
Minimum allowed line rate is Module Tests Coverage
|



This PR introduces response compression support and simplifies HTTP client configuration by centralizing Accept‑Encoding logic.
Key Changes
Introduced a static internal list:
private static readonly IReadOnlyCollection<string> AcceptEncodings = ["br", "gzip"];All configured HttpClient instances now consistently apply:
Added automatic decompression in HttpClientHandler for: