Skip to content

Commit

Permalink
Fix client to distinguish between forms and other contents
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Oct 11, 2023
1 parent 24d58fa commit 59d1f68
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions lib/ApiClient/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,29 @@ private function execute(
array $formData = []
): Response {
try {
/** @var GuzzleResponse $response */
$guzzleResponse = $this->guzzle->request(
$method,
$url,
[
'headers' => $headers,
'body' => $content,
'form_params' => $formData,
'timeout' => 30
]
);
if ($formData) {
/** @var GuzzleResponse $response */
$guzzleResponse = $this->guzzle->request(
$method,
$url,
[
'headers' => $headers,
'form_params' => $formData,
'timeout' => 30
]
);
} else {
/** @var GuzzleResponse $response */
$guzzleResponse = $this->guzzle->request(
$method,
$url,
[
'headers' => $headers,
'body' => $content,
'timeout' => 30
]
);
}
} catch (ConnectException $e) {
if (str_contains($e->getMessage(), 'cURL error 28')) {
throw new HttpTimeOutException();
Expand Down

0 comments on commit 59d1f68

Please sign in to comment.