Skip to content

[13.x] Add withoutHeader() and withoutHeaders() to HTTP client Pendin…#60667

Open
Amirhf1 wants to merge 2 commits into
laravel:13.xfrom
Amirhf1:feat/http-client-without-header
Open

[13.x] Add withoutHeader() and withoutHeaders() to HTTP client Pendin…#60667
Amirhf1 wants to merge 2 commits into
laravel:13.xfrom
Amirhf1:feat/http-client-without-header

Conversation

@Amirhf1

@Amirhf1 Amirhf1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

This PR adds withoutHeader() and withoutHeaders() methods to the HTTP client's PendingRequest, allowing removal of headers before a request is sent.

The client currently supports adding headers (withHeader(), withHeaders(), replaceHeaders()) but offers no fluent way to remove one. This mirrors the withoutHeader() method recently added to ResponseTrait and the existing withCookie()/withoutCookie() symmetry, completing the header API.

Use Cases

  • Removing a default header set by a base client or Http::macro
  • Stripping a header for a single request without rebuilding the client
  • Removing sensitive headers (e.g. X-Debug, Authorization) before proxying

Usage

Http::withHeaders(['X-Debug' => '1'])
    ->withoutHeader('X-Debug')
    ->withoutHeaders(['X-Trace', 'X-Internal'])
    ->get('https://example.com');

Comment thread src/Illuminate/Http/Client/PendingRequest.php Outdated
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