Skip to content

[4.x] Detect HEAD requests case-insensitively in the cURL transport - #95

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-curl-head-case
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-curl-head-case

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

The cURL transport upper-cases the method for the request (CURLOPT_CUSTOMREQUEST) but set CURLOPT_NOBODY only for $method === 'HEAD'. A lower-case head, which can come from a PSR-7 request passed to sendRequest() or from a direct transport call, was therefore sent as a custom HEAD request with NOBODY disabled. cURL then waits for the body that the response's Content-Length announces but a HEAD response never carries: on a keep-alive connection until the timeout ("Operation timed out … with 0 out of 100 bytes received"), on a closing one it fails with "transfer closed with 100 bytes remaining to read".

CURLOPT_NOBODY is now set for the method name in any case. The stream and socket transports were not affected.

Testing Instructions

Tests/Transport/HeadRequestTest.php (new) sends HEAD and head with each transport to the new stub Tests/stubs/content_length.php, which announces a 100-byte body; the web server omits it for HEAD. Before the change cURL with head fails with "transfer closed with 100 bytes remaining to read"; after it all six cases return 200 with an empty body.

Documentation Changes Required

docs/overview.md, "Making a HEAD request": the response has no body, whatever the case of the method name.

🤖 Generated with Claude Code

The cURL transport upper-cased the method for the request line but set
CURLOPT_NOBODY only for exactly "HEAD". A lower-case "head", which can come
from a PSR-7 request or a direct transport call, was sent as a custom HEAD
request with NOBODY disabled, so cURL waited for the body announced by
Content-Length until the connection was closed or the request timed out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hackwar

Hackwar commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Approved

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