Repository navigation
tool: append buffered response headers in constant time - #23352
Closed
cla7aye15I4nd wants to merge 8 commits into
Closed
cla7aye15I4nd wants to merge 8 commits into
cla7aye15I4nd wants to merge 8 commits into
Conversation
cla7aye15I4nd
marked this pull request as ready for review
October 11, 2026 08:01
There was a problem hiding this comment.
🟢 Approval recommended
The changes preserve ordering and cleanup semantics while eliminating repeated list traversal.
0 open findings
What changed in this PR
Optimizes buffered response-header appends from quadratic to constant time.
Changes:
- Uses
slist_wccached-tail lists for buffered headers. - Ensures cleanup across flush, failure, and transfer completion.
- Makes
slist_wcavailable without--libcurlsupport.
| File | Description |
|---|---|
src/tool_operate.c |
Frees the wrapped header list during cleanup. |
src/tool_cb_hdr.h |
Changes buffered-header storage to slist_wc. |
src/tool_cb_hdr.c |
Appends and flushes headers through the wrapper. |
src/slist_wc.h |
Exposes the wrapper for all configurations. |
src/slist_wc.c |
Builds the wrapper implementation unconditionally. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cla7aye15I4nd
marked this pull request as draft
October 15, 2026 05:28
cla7aye15I4nd
marked this pull request as ready for review
October 15, 2026 06:37
cla7aye15I4nd
marked this pull request as draft
October 15, 2026 07:41
cla7aye15I4nd
marked this pull request as ready for review
October 15, 2026 07:52
cla7aye15I4nd
marked this pull request as draft
October 15, 2026 08:41
cla7aye15I4nd
marked this pull request as ready for review
October 15, 2026 17:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With -OJ --show-headers, buffering each response header walks the existing curl_slist, making construction quadratic. Reuse the tool's slist_wc wrapper to append in constant time while retaining received order. Make the wrapper available when CURL_DISABLE_LIBCURL_OPTION is enabled, and release it on flush, error and transfer cleanup.
Validation: normal debug build and a build with CURL_DISABLE_LIBCURL_OPTION=ON and CURL_DISABLE_HEADERS_API=ON both compile. External local-server checks compare the complete output bytes for ordinary headers, repeated headers, a 100 Continue response, a late Content-Disposition filename and a 4,000-header response with a body; all three cases pass in both configurations. Existing --libcurl tests 1400-1405 pass. Test 4657 was skipped by the local test runner. Source-format and whitespace checks pass.
The earlier constant-time implementation measured 20k/40k/60k short headers at approximately 22/24/26 ms versus 177/662/1451 ms before the patch; the current implementation uses the existing cached-tail abstraction for the same algorithm.