fix(http): compress empty encoded responses#152
Conversation
yordis
commented
May 2, 2026
- Prevents clients from receiving a declared gzip or deflate response that has no compressed payload to decode.
- Keeps HTTP compression behavior consistent for empty and non-empty responses.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit b78b901. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughEmpty HTTP responses are now compressed when clients advertise ChangesEmpty Payload Compression
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing [Slack Agent](https://www.coderabbit.ai/agent): Turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 👉 Get your free trial and get 200 agent minutes per Slack user (a $50 value). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 54 minutes and 10 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/EventStore.Core.Tests/Services/Transport/Http/compress_response_should.cs (1)
84-112: 💤 Low valueConsider adding a symmetric integration test for deflate.
There's
empty_gzip_reply_has_a_valid_gzip_bodybut no equivalentempty_deflate_reply_has_a_valid_deflate_body. Since theReplycode path treats both algorithms identically and unit-level coverage exists for deflate, this is low risk—but adding the test would ensure complete parity.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/EventStore.Core.Tests/Services/Transport/Http/compress_response_should.cs` around lines 84 - 112, Add a parallel test to empty_gzip_reply_has_a_valid_gzip_body that verifies deflate behavior: create a new test method (e.g., empty_deflate_reply_has_a_valid_deflate_body) that sets context.Request.Headers["Accept-Encoding"] = CompressionAlgorithms.Deflate, calls manager.Reply(Array.Empty<byte>(), 200, "OK", "text/plain", Encoding.UTF8, null, ex => error = ex) on the same HttpEntity/manager setup, assert the response header context.Response.Headers["Content-Encoding"] equals CompressionAlgorithms.Deflate, confirm responseBody.Length > 0 and then decompress using System.IO.Compression.DeflateStream to verify the uncompressed output length is 0 and error is null and the completed event was signaled.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/EventStore.Core.Tests/Services/Transport/Http/compress_response_should.cs`:
- Around line 84-112: Add a parallel test to
empty_gzip_reply_has_a_valid_gzip_body that verifies deflate behavior: create a
new test method (e.g., empty_deflate_reply_has_a_valid_deflate_body) that sets
context.Request.Headers["Accept-Encoding"] = CompressionAlgorithms.Deflate,
calls manager.Reply(Array.Empty<byte>(), 200, "OK", "text/plain", Encoding.UTF8,
null, ex => error = ex) on the same HttpEntity/manager setup, assert the
response header context.Response.Headers["Content-Encoding"] equals
CompressionAlgorithms.Deflate, confirm responseBody.Length > 0 and then
decompress using System.IO.Compression.DeflateStream to verify the uncompressed
output length is 0 and error is null and the completed event was signaled.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 504582cd-0f22-4e52-9ad8-c8c88746aeef
📒 Files selected for processing (2)
src/EventStore.Core.Tests/Services/Transport/Http/compress_response_should.cssrc/EventStore.Transport.Http/EntityManagement/HttpEntityManager.cs
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>