Skip to content

Commit

Permalink
Update HttpBodyTrait.php
Browse files Browse the repository at this point in the history
  • Loading branch information
evasyakin committed Aug 29, 2021
1 parent d4b3e8b commit 970e4ab
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Traits/HttpBodyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 970e4ab

Please sign in to comment.