Skip to content

Fix HttpClient::withOptions() renumbering integer CURLOPT_* keys - #131

Merged
benkhalife merged 1 commit into
masterfrom
fix/httpclient-withoptions-integer-keys
Nov 21, 2026
Merged

benkhalife merged 1 commit into
masterfrom
fix/httpclient-withoptions-integer-keys

Conversation

@benkhalife

Copy link
Copy Markdown
Member

withOptions() merged with array_merge(), which renumbers integer keys. Every CURLOPT_* constant is an integer, so the options reached curl_setopt() as 0, 1, 2, ... and the request threw "ValueError: Argument #2 ($option) is not a valid cURL option".

Merge with the + operator instead: integer keys are preserved and, on a clash, the newly passed value wins (same precedence as before).

Adds two regression tests: an option is actually applied, and options merge across calls with the last value winning.

withOptions() merged with array_merge(), which renumbers integer keys. Every
CURLOPT_* constant is an integer, so the options reached curl_setopt() as
0, 1, 2, ... and the request threw "ValueError: Argument #2 ($option) is
not a valid cURL option".

Merge with the + operator instead: integer keys are preserved and, on a
clash, the newly passed value wins (same precedence as before).

Adds two regression tests: an option is actually applied, and options merge
across calls with the last value winning.
@benkhalife
benkhalife merged commit ce119ab into master Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant