Skip to content

Implement Response Compression and Centralize Accept‑Encoding Handling in HTTP Client Configuration #86

Open
mm-hsh wants to merge 7 commits intodevelopfrom
feature/614-Response-Compression
Open

Implement Response Compression and Centralize Accept‑Encoding Handling in HTTP Client Configuration #86
mm-hsh wants to merge 7 commits intodevelopfrom
feature/614-Response-Compression

Conversation

@mm-hsh
Copy link
Contributor

@mm-hsh mm-hsh commented Mar 26, 2026

This PR introduces response compression support and simplifies HTTP client configuration by centralizing Accept‑Encoding logic.

Key Changes

  1. Centralized Accept-Encoding Configuration
  • Introduced a static internal list:

  • private static readonly IReadOnlyCollection<string> AcceptEncodings = ["br", "gzip"];

  • All configured HttpClient instances now consistently apply:

    • Accept-Encoding: br
    • Accept-Encoding: gzip
  • Added automatic decompression in HttpClientHandler for:

    • Brotli
    • GZip
  1. Added Response Compression to the API (Program.cs)
  • Enabled built‑in ASP.NET Core response compression middleware.
  • Added providers:
    • BrotliCompressionProvider
    • GzipCompressionProvider

mm-hsh added 2 commits March 26, 2026 10:55
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.
Copilot AI review requested due to automatic review settings March 26, 2026 09:31
@github-actions
Copy link

github-actions bot commented Mar 26, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AcceptEncodings list and applied Accept-Encoding headers to resilient HttpClient registrations.
  • Enabled automatic decompression (Brotli/Gzip) on the primary HttpClientHandler for 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.

@mm-hsh mm-hsh changed the title Implement Response Compression and Centralize Accept‑Encoding Handling in HTTP Client Configuration Implement Response Compression and Centralize Accept‑Encoding Handling in HTTP Client Configuration Mar 26, 2026
@mm-hsh mm-hsh requested a review from Copilot March 26, 2026 10:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

mm-hsh added 4 commits March 26, 2026 15:55
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.
@sonarqubecloud
Copy link

@github-actions
Copy link

Test & Coverage Report

Test Results Summary

Metric Count
✅ Passed 1023
❌ Failed 0
⏭️ Skipped 0

View Detailed Test Results


Code Coverage

Unit Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 91% 83% 1515
Summary 91% (2576 / 2820) 83% (1084 / 1305) 1515

Minimum allowed line rate is 80%

Module Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 55% 42% 1515
Summary 55% (1560 / 2820) 42% (543 / 1305) 1515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants