Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
add content type header when sending request
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch committed Dec 6, 2022
1 parent f0f13d6 commit a06e5a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ public function command(string $part, string $command, array $parameters = []):
private function post(array $data): Response
{
try {
$body = new StringStream(\http_build_query($data, '', '&'));
$response = $this->client->sendRequest(
$this->requestFactory->createRequest('POST', $this->address)
->withBody(new StringStream(\http_build_query($data, '', '&')))
->withHeader('Content-Length', $body->getSize())
->withHeader('Content-Type', 'application/x-www-form-urlencoded')
->withBody($body)
);

$responseStatus = $response->getStatusCode();
Expand All @@ -54,7 +57,6 @@ private function post(array $data): Response
);
}
} catch (ClientExceptionInterface $e) {
\var_dump($e);
throw new ResponseException(
"Request failed with command {$data['command']}, {$e->getMessage()}",
$e->getCode(),
Expand Down

0 comments on commit a06e5a8

Please sign in to comment.