-
-
Notifications
You must be signed in to change notification settings - Fork 304
fix: pass through respose body after process partial #1461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: pass through respose body after process partial #1461
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1461 +/- ##
==========================================
- Coverage 85.27% 85.24% -0.03%
==========================================
Files 173 173
Lines 8400 8411 +11
==========================================
+ Hits 7163 7170 +7
- Misses 991 993 +2
- Partials 246 248 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where response body data was not being passed through to downstream after partial processing when the response body limit is reached with ProcessPartial action. The fix ensures that when WriteResponseBody returns fewer bytes than provided (indicating partial processing), the remaining bytes are written directly to the downstream writer.
Key changes:
- Extracted buffered response body write logic into a reusable method to avoid duplication
- Modified the
Writemethod to pass through remaining bytes after partial processing - Added comprehensive test coverage for various response body processing scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| http/interceptor.go | Added wroteBufferedBodyToDownstream flag to track state, created writeBufferedResponseBodyToDownstream() helper method, and updated Write() method to handle partial writes by passing through remaining bytes |
| http/interceptor_test.go | Added comprehensive TestResponseBody test function covering multiple scenarios including limit rejection, partial processing with and without data leaks, and chunked response handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ports to upstream corazawaf/coraza-caddy#235.
cc @hnakamur