diff --git a/src/HttpClient.php b/src/HttpClient.php index b6b5afb..a7db799 100644 --- a/src/HttpClient.php +++ b/src/HttpClient.php @@ -154,7 +154,8 @@ private function prepareOptions(array $params = array()) $options = array(); if (count($params) > 0) { - $options[RequestOptions::JSON] = $params; + $options[RequestOptions::FORM_PARAMS] = $params; + $options[RequestOptions::VERIFY] = false; $body = json_encode($params); } else { $body = ''; @@ -162,8 +163,8 @@ private function prepareOptions(array $params = array()) $defaultHeaders = array( 'User-Agent' => 'elmage/textng/php/'.Client::VERSION, - 'Content-Type' => 'application/json', - 'Accept' => 'text/plain, application/json', + 'Content-Type' => 'application/x-www-form-urlencoded', + 'Accept' => 'text/plain, application/json', 'text/html', ); $options[RequestOptions::HEADERS] = $defaultHeaders; diff --git a/tests/Unit/HttpClientTest.php b/tests/Unit/HttpClientTest.php index 0ba7db8..41507af 100644 --- a/tests/Unit/HttpClientTest.php +++ b/tests/Unit/HttpClientTest.php @@ -8,6 +8,7 @@ use Elmage\TextNg\HttpClient; use Elmage\TextNg\Configuration; use GuzzleHttp\Psr7\Response; +use GuzzleHttp\RequestOptions; use PHPUnit\Framework\Constraint\Callback; use PHPUnit\Framework\MockObject\MockObject; use GuzzleHttp\ClientInterface; @@ -119,15 +120,15 @@ function ($request) use ($method, $path) { ); } - private function isValidOptionsArray(array $headers = [], $json = true): Callback + private function isValidOptionsArray(array $headers = [], $form_params = true): Callback { - return $this->callback(function ($options) use ($headers, $json) { + return $this->callback(function ($options) use ($headers, $form_params) { $this->assertArrayHasKey('headers', $options); $this->assertArrayHasKey('User-Agent', $options['headers']); $this->assertArrayHasKey('Content-Type', $options['headers']); - if ($json) { - $this->assertArrayHasKey('json', $options); + if ($form_params) { + $this->assertArrayHasKey(RequestOptions::FORM_PARAMS, $options); } foreach ($headers as $header) {