Repository navigation
Support CURLOPT_PREREQFUNCTION in coroutine curl handler - #190
Merged
Merged
Conversation
Contributor
Author
|
These failures don't look related to this change. |
deminy
self-requested a review
July 27, 2026 04:23
deminy
approved these changes
Jul 28, 2026
deminy
added a commit
that referenced
this pull request
Jul 28, 2026
Polish the CURLOPT_PREREQFUNCTION support added in PR #190: - Polyfill CURLOPT_PREREQFUNCTION, CURL_PREREQFUNC_OK and CURL_PREREQFUNC_ABORT in src/constants.php (like the other libcurl-version-gated CURLOPT_* constants), turning the special-cased default: branch of Handler::setOption() into a plain case. - Actually invoke the callback before each request (once per redirect hop) with the five native arguments; real socket addresses are reported when an established connection is reused. Returning CURL_PREREQFUNC_ABORT aborts the transfer with CURLE_ABORTED_BY_CALLBACK before any I/O, and other return values throw ValueError/TypeError as native cURL does. - Replace the setopt-only test with behavioral tests against the local httpbin service: invocation and arguments, per-hop invocation on redirects, abort semantics, invalid return values, and clearing the callback with null (Guzzle's release path). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Sep 27, 2026
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.
Guzzle 7.13 registers
CURLOPT_PREREQFUNCTIONand sets it back tonullwhen it releases each handle. UnderSWOOLE_HOOK_CURLthat call lands inHandler::setOption(), which doesn't know the option and throwsswoole_curl_setopt(): option[20312] is not supported, so every request made through Guzzle blows up. This accepts the option the same way the other callback options are handled. The constant only exists on PHP 8.2+ with libcurl 7.80 or newer, so it's guarded withdefined()to avoid breaking older builds.Fixes swoole/swoole-src#6098