Skip to content

[13.x] Add Http::query() method to the HTTP client#60663

Open
shanerbaner82 wants to merge 1 commit into
laravel:13.xfrom
shanerbaner82:add-http-client-query-method
Open

[13.x] Add Http::query() method to the HTTP client#60663
shanerbaner82 wants to merge 1 commit into
laravel:13.xfrom
shanerbaner82:add-http-client-query-method

Conversation

@shanerbaner82

Copy link
Copy Markdown

The HTTP QUERY method was recently published as RFC 10008 on the IETF Standards Track: a safe, cacheable method that carries its query in the request body, enabling expressive queries without the URL-length and cacheability trade-offs of GET vs. POST.

Support for QUERY is landing across the ecosystem — Symfony chose its HTTP client as the first component to support it — and it is arriving in Laravel via #60655 (routing, master) and #60662 (testing helpers, 13.x). This PR completes the story for the consuming side: Laravel's HTTP client has a method per verb (get, head, post, put, patch, delete) but no way to issue a QUERY request without dropping down to Http::send('QUERY', ...).

$response = Http::query('https://api.example.com/search', [
    'filter' => ['status' => 'active'],
]);

The method mirrors post() exactly: data is sent in the request body using the pending request's body format (JSON by default, form-urlencoded via asForm(), etc.), which matches RFC 10008's body-carried query semantics. withQueryParameters() and the $query argument to get() are unaffected and continue to control the query string.

Fully backward compatible — purely additive, no contracts changed, and PendingRequest had no existing query() method. Tests cover the default JSON body format and asForm(), asserting the method and body placement through Http::fake().

Related: #60655, #60662, discussion #60564

🤖 Generated with Claude Code

Adds a query() method to the HTTP client, issuing requests using the
HTTP QUERY method (RFC 10008) with the data carried in the request
body, mirroring the existing post/put/patch/delete helpers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Vectorial1024

Copy link
Copy Markdown

Concept first mentioned by issue #60564, in case we want extra discussion.

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.

2 participants