Skip to content

Commit

Permalink
Check body for string
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Mar 22, 2019
1 parent b29eb03 commit f7067ae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Common/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ private function getStreamFactory() : StreamFactoryInterface
* @param $method
* @param $uri
* @param array $headers
* @param string|array|resource|StreamInterface|null $body
* @param string|null $body
* @param string $protocolVersion
* @return ResponseInterface
* @throws \Http\Client\Exception
* @throws NetworkException|RequestException
*/
public function request(
$method,
Expand All @@ -86,9 +86,9 @@ public function request(
->createRequest($method, $uri)
->withProtocolVersion($protocolVersion);

if ($body) {
$stream = $this->getStreamFactory()->createStream($body);
$request = $request->withBody($stream);
if ($body !== null && $body !== '' && is_string($body)) {
$body = $this->getStreamFactory()->createStream($body);
$request = $request->withBody($body);
}

foreach ($headers as $name => $value) {
Expand Down

0 comments on commit f7067ae

Please sign in to comment.