Skip to content

[9.x] Fix: prevent duplicated content-type on HTTP client#45960

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
danilopolani:fix/http-client-duplicated-content-type
Feb 4, 2023
Merged

[9.x] Fix: prevent duplicated content-type on HTTP client#45960
taylorotwell merged 2 commits into
laravel:9.xfrom
danilopolani:fix/http-client-duplicated-content-type

Conversation

@danilopolani

Copy link
Copy Markdown
Contributor

The PR fixes a weird behaviour where calling multiple times a method that sets a content type (or manually) will append the same content type duplicated, eventually causing issues with external APIs (especially with Express middlewares etc.).

Sample to reproduce the old behaviour:

use Illuminate\Support\Facades\Http;

$client = Illuminate\Support\Facades\Http::asJson();

$client->asJson();
$client->asJson();
dd($client->getOptions()['headers']['Content-Type']);

Output

image

@taylorotwell taylorotwell merged commit 490713a into laravel:9.x Feb 4, 2023
@danilopolani danilopolani deleted the fix/http-client-duplicated-content-type branch February 4, 2023 15:43
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