Skip to content

Fix/httpclient bugs#119

Merged
benkhalife merged 3 commits into
masterfrom
fix/httpclient-bugs
Jun 21, 2026
Merged

Fix/httpclient bugs#119
benkhalife merged 3 commits into
masterfrom
fix/httpclient-bugs

Conversation

@benkhalife

Copy link
Copy Markdown
Member

No description provided.

This commit fixes 8 distinct bugs in HttpClient, all of them confirmed
by a new test suite (tests/HttpClientTest.php, 37 tests / 72 assertions).

Bugs fixed:
1. Base URL was discarded when a relative path was passed to a verb
   method. Track baseUrl separately and join relative paths to it.
2. Multipart uploads using the documented '@/path' syntax silently sent
   the literal string. Convert such values to CURLFile and clear any
   stale Content-Type so cURL can attach the correct multipart boundary.
3. HTTP header injection (CWE-93) was possible because withHeader()
   accepted CR/LF in names and values. Reject them with
   InvalidArgumentException.
4. parseResponse() collapsed duplicate response headers, so multiple
   Set-Cookie headers were lost. Preserve repeats as arrays and use
   only the final hop's headers when redirects are followed.
5. HttpResponse::header() lookups were case-sensitive, contrary to
   RFC 7230. Compare with strcasecmp().
6. queryParams, body and url leaked from one request to the next on
   the same client. Clear them after each send(); persistent settings
   (headers, auth, timeouts) deliberately remain.
7. asJson() silently sent an empty body when json_encode() returned
   false. Throw RuntimeException with json_last_error_msg().
8. reset() only cleared a subset of fields. Restore every request-
   shaping property to its initial value (preserving baseUrl).

All pre-existing tests pass with no regression.
@benkhalife
benkhalife merged commit 16198e7 into master Jun 21, 2026
1 check 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