From 970e4abec31981c233e3be762462c181a4f29b7a Mon Sep 17 00:00:00 2001 From: Egor Vasyakin Date: Sun, 29 Aug 2021 19:08:37 +0300 Subject: [PATCH] Update HttpBodyTrait.php --- src/Traits/HttpBodyTrait.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Traits/HttpBodyTrait.php b/src/Traits/HttpBodyTrait.php index b95b230..2b28a9f 100644 --- a/src/Traits/HttpBodyTrait.php +++ b/src/Traits/HttpBodyTrait.php @@ -45,6 +45,9 @@ public function withAddedBody(string $body): object */ public function withBodyJson($body): object { + if (!$this->hasHeader('Content-Type')) { + $this->withHeader('Content-Type', 'application/json'); + } return $this->withBody(json_encode($body)); }