Skip to content

Commit

Permalink
do not set GET/HEAD request body
Browse files Browse the repository at this point in the history
  • Loading branch information
fenric committed Jan 9, 2022
1 parent b9bb96b commit c63e743
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use function curl_multi_close;
use function curl_setopt_array;
use function explode;
use function in_array;
use function sprintf;
use function strpos;
use function substr;
Expand Down Expand Up @@ -168,7 +169,10 @@ private function createCurlHandleFromRequest(RequestInterface $request)

$curlOptions[CURLOPT_CUSTOMREQUEST] = $request->getMethod();
$curlOptions[CURLOPT_URL] = (string) $request->getUri();
$curlOptions[CURLOPT_POSTFIELDS] = (string) $request->getBody();

if (!in_array($request->getMethod(), ['GET', 'HEAD'], true)) {
$curlOptions[CURLOPT_POSTFIELDS] = (string) $request->getBody();
}

foreach ($request->getHeaders() as $name => $values) {
foreach ($values as $value) {
Expand Down

0 comments on commit c63e743

Please sign in to comment.