Conversation
lib/http/HttpClient_Curl.hpp: Use a pre-request hook to preserve event order while issuing one transfer on curl 7.80+. tests/unittests/HttpClientCurlTests.cpp: Cover connection counts, cancellation, state order, and callback failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 695c3a98-72f2-4247-afb3-7d4b0bbc34a5
lib/http/HttpClient_Curl.hpp: Propagate global-init failures, initialize the handle safely, and abort vector writes rather than unwinding through libcurl. lib/http/HttpClient_Curl.cpp: Report initialization failures without calling curl_version_info on a failed library. tests/unittests/HttpClientCurlTests.cpp: Verify initialization and synchronize the abort-before-accept regression. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 695c3a98-72f2-4247-afb3-7d4b0bbc34a5
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Runtime-version fallback and callback reentrancy/state-event issues remain unresolved.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Updates the curl transport to avoid redundant connections while preserving telemetry state events and improving failure safety.
Changes:
- Uses
CURLOPT_PREREQFUNCTIONfor modern libcurl. - Handles global initialization and callback allocation failures.
- Adds connection, cancellation, binary POST, and exception tests.
| File | Description |
|---|---|
lib/http/HttpClient_Curl.hpp |
Implements connection-ready callbacks and safety handling. |
lib/http/HttpClient_Curl.cpp |
Propagates global initialization failures. |
tests/unittests/HttpClientCurlTests.cpp |
Adds transport regression coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Copilot comment 4114465995: runtime libcurl may be older than build headers. Probe the loaded library after global init and install CURLOPT_PREREQFUNCTION only on 7.80+; route Send() through the existing connect-only path otherwise. Verified at CMakeLists.txt:219-242 and lib/http/HttpClient_Curl.hpp:293-337. Files changed: lib/http/HttpClient_Curl.hpp, tests/unittests/HttpClientCurlTests.cpp. Check connection counts against the runtime transport path, including GET and binary POST. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5fa346e8-a5c8-4324-8144-a4a867cb146e
Copilot comment 4114543078: sample listeners in examples/cpp/SampleCpp/DebugCallback.cpp:79-86 and examples/cpp/MacProxy/HttpEventListener.cpp:38-45 set options on non-null handles. OnSending on curl 7.80+ now passes null while OnConnecting retains its pre-transfer handle; legacy timing and handle access stay unchanged. Files changed: lib/http/HttpClient_Curl.hpp, lib/include/public/IHttpClient.hpp, tests/unittests/HttpClientCurlTests.cpp. Document callback handle availability and assert both runtime paths in loopback tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5fa346e8-a5c8-4324-8144-a4a867cb146e
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation preserves older-runtime behavior and adds focused coverage for connection reuse, callback ordering, cancellation, and failure paths.
Review effort: Balanced
Findings: None
Resolved since last review (1)
This branch has not been deployed
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.

Why
A single telemetry HTTP send currently performs
CURLOPT_CONNECT_ONLYand then the actual HTTP transfer. libcurl documents that connect-only connections cannot be reused; a loopback regression against curl 8.22.0 observed two TCP accepts for one GET before this change. The readiness poll therefore checks a different connection from the one carrying the request.What changed
CURLOPT_PREREQFUNCTIONto dispatchOnSendingafter connection establishment and before the HTTP request, within one transfer. Preserve connect/send failure events and abort on cancellation or callback exceptions without unwinding through libcurl.OnSending, and exceptions raised by anOnSendingobserver.OnSendingis now delivered from a libcurl callback on curl 7.80+, rather than between two transfers. On curl 7.80+, OnSending runs inside libcurl and receives a null handle to prevent in-transfer option changes; configure curl on the OnConnecting event instead. Older curl retains the legacy event timing and handle.Additional curl safety fixes
curl_global_initfailures as creation/local failures without calling other curl APIs after failed initialization; keep the handle null for safe teardown.CURLE_WRITE_ERROR) rather than unwinding through libcurl's C callback, when C++ exceptions are enabled. No-exceptions builds also compile.OnSendingobserver aborts the transfer immediately.Validation
-fno-exceptionsagainst curl 8.22.0 headers.git diff --checkpassed.This fixes the demonstrated extra connection, not a proven root cause of the reported
Curl_wildcard_dtorSIGSEGV. The crash report has no core, faulting instruction, registers, or loaded-module map to establish that cause.