Skip to content

Commit

Permalink
Remove json issue. #4
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Mar 7, 2018
1 parent c434c09 commit b50da41
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/Traits/HasHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ public function request($uri, $method = 'GET', $options = []): ResponseInterface

$options = array_merge(self::$defaults, $options, ['handler' => $this->getHandlerStack()]);

$options = $this->fixJsonIssue($options);

$response = $this->getHttpClient()->request($method, $uri, $options);
$response->getBody()->rewind();

Expand Down Expand Up @@ -192,26 +190,4 @@ public function getHandlerStack(): HandlerStack

return $this->handlerStack;
}

/**
* @param array $options
*
* @return array
*/
protected function fixJsonIssue(array $options): array
{
if (isset($options['json']) && is_array($options['json'])) {
$options['headers'] = array_merge($options['headers'] ?? [], ['Content-Type' => 'application/json']);

if (empty($options['json'])) {
$options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_FORCE_OBJECT);
} else {
$options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_UNESCAPED_UNICODE);
}

unset($options['json']);
}

return $options;
}
}

0 comments on commit b50da41

Please sign in to comment.