-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add trailer parsing logic #11269
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
Add trailer parsing logic #11269
Conversation
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #11269 +/- ##
==========================================
- Coverage 98.84% 98.84% -0.01%
==========================================
Files 131 131
Lines 43262 43258 -4
Branches 2327 2326 -1
==========================================
- Hits 42761 42757 -4
Misses 346 346
Partials 155 155
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #11269 will not alter performanceComparing Summary
|
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
… add-trailer-parser
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 adds support for parsing HTTP trailers in the core parser and updates tests to exercise the new logic without yet exposing a public API.
- Integrates
HeadersParser
intoHttpPayloadParser
and HTTP parsing routines for trailer extraction. - Updates and adds tests for valid and invalid trailer parsing scenarios.
- Adjusts multipart header reader initialization and records the feature in CHANGES.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/test_http_parser.py | Added new trailer tests and updated HttpPayloadParser instantiations with HeadersParser . |
aiohttp/multipart.py | Changed _read_headers initialization to start with an empty list. |
aiohttp/http_parser.py | Integrated trailer parsing logic, mandatory headers_parser injection, and adjusted parse_headers slicing. |
CHANGES/11269.feature.rst | Logged the initial trailer parsing feature. |
Comments suppressed due to low confidence (4)
aiohttp/http_parser.py:769
- Adding a mandatory headers_parser parameter to HttpPayloadParser is a breaking change. Consider providing a default value (e.g., headers_parser: HeadersParser = HeadersParser()) to maintain backward compatibility.
headers_parser: HeadersParser,
CHANGES/11269.feature.rst:1
- [nitpick] The change log entry is succinct but could be expanded to briefly describe what trailer parsing covers and note that the API is not yet public-facing.
Added initial trailer parsing logic -- by :user:`Dreamsorcerer`.
aiohttp/multipart.py:784
- Initializing
lines
as an empty list may skip the expected placeholder and could lead to out-of-bounds in downstream header parsing. Ensure that the new list state correctly represents the first header line or reintroduce a sentinel if needed.
lines = []
tests/test_http_parser.py:1640
- [nitpick] Tests repeatedly instantiate HttpPayloadParser with a HeadersParser argument; consider refactoring to use a fixture or default constructor value to reduce boilerplate.
p = HttpPayloadParser(out, headers_parser=HeadersParser())
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.
Looks good. I didn't find any logic errors. 👍
Backport to 3.12: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 7dd4b55 on top of patchback/backports/3.12/7dd4b5535e6bf9c2d2f05fde638517bff065ba74/pr-11269 Backporting merged PR #11269 into master
🤖 @patchback |
Backport to 3.13: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 7dd4b55 on top of patchback/backports/3.13/7dd4b5535e6bf9c2d2f05fde638517bff065ba74/pr-11269 Backporting merged PR #11269 into master
🤖 @patchback |
(cherry picked from commit 7dd4b55)
(cherry picked from commit 7dd4b55)
This adds trailer parsing to the parsing logic. First step towards #1652.
It does not yet expose the trailers, so there are no visible user changes, but paves the way for a future PR to add the public API to these.