Skip to content

Implement response compression for Testplugin #87

Open
mm-hsh wants to merge 1 commit intodevelopfrom
feature/614-Response-Compression-TestPlugin
Open

Implement response compression for Testplugin #87
mm-hsh wants to merge 1 commit intodevelopfrom
feature/614-Response-Compression-TestPlugin

Conversation

@mm-hsh
Copy link
Contributor

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

This pull request adds support for HTTP response compression to improve performance and reduce bandwidth usage in the AAS.TwinEngine.Plugin.TestPlugin application. The main changes involve configuring Brotli and Gzip compression providers and enabling response compression for HTTPS traffic.

Response Compression Enhancements:

  • Added and configured Brotli and Gzip response compression providers in the Program.cs startup logic, enabling compression for HTTPS responses and setting both providers to use optimal compression level.
  • Enabled response compression middleware in the application pipeline to ensure compressed responses are served to clients.

Added Brotli and Gzip response compression to the ASP.NET Core app with optimal compression levels. Registered providers in service configuration and enabled middleware to improve performance and reduce bandwidth usage.
Copilot AI review requested due to automatic review settings March 26, 2026 11:43
@github-actions
Copy link

Dependency Review

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

Scanned Files

None

@sonarqubecloud
Copy link

@github-actions
Copy link

Test & Coverage Report

Test Results Summary

Metric Count
✅ Passed 1019
❌ 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% 1504
Summary 91% (2551 / 2801) 83% (1075 / 1295) 1504

Minimum allowed line rate is 80%

Module Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 56% 42% 1504
Summary 56% (1559 / 2801) 42% (540 / 1295) 1504

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 HTTP response compression to AAS.TwinEngine.Plugin.TestPlugin to reduce bandwidth usage and improve response performance for clients.

Changes:

  • Registers Brotli and Gzip response compression providers and configures both to CompressionLevel.Optimal.
  • Enables response compression for HTTPS traffic.
  • Adds UseResponseCompression() to the middleware pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +28
_ = builder.Services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
options.Providers.Add<GzipCompressionProvider>();
});
_ = builder.Services.Configure<BrotliCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
_ = builder.Services.Configure<GzipCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

New code uses discard assignments (_ = ...) for service registration, but the rest of this Program.cs uses direct calls (e.g., builder.Services.AddControllers()). This inconsistency makes the startup code harder to scan and suggests two different style conventions in the same file. Consider removing the discards here (or applying the same pattern consistently throughout this file).

Suggested change
_ = builder.Services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
options.Providers.Add<GzipCompressionProvider>();
});
_ = builder.Services.Configure<BrotliCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
_ = builder.Services.Configure<GzipCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
builder.Services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
options.Providers.Add<GzipCompressionProvider>();
});
builder.Services.Configure<BrotliCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
builder.Services.Configure<GzipCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +24
{
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Enabling response compression for HTTPS (EnableForHttps = true) can increase exposure to BREACH-style attacks if any endpoints reflect secrets into responses while an attacker can influence part of the plaintext. Please confirm this service doesn’t return sensitive reflected content (tokens, secrets, CSRF values, etc.), or limit compression to non-sensitive content types/endpoints (and consider making this setting environment-configurable).

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +28
_ = builder.Services.Configure<BrotliCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
_ = builder.Services.Configure<GzipCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal);
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

CompressionLevel.Optimal for both Brotli and Gzip can be CPU-expensive and may increase latency under load; for APIs it’s common to use a faster level (or make the level configurable per environment). Consider switching to a faster default and/or reading the level from configuration so it can be tuned without code changes.

Copilot uses AI. Check for mistakes.
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