Fix Guzzle InvalidArgumentException for POST with array parameters
This commit is contained in:
@@ -140,6 +140,10 @@ class HttpClient implements ICanSendHttpRequests
|
||||
$conf[RequestOptions::BODY] = $opts[HttpClientOptions::BODY];
|
||||
}
|
||||
|
||||
if (!empty($opts[HttpClientOptions::FORM_PARAMS])) {
|
||||
$conf[RequestOptions::FORM_PARAMS] = $opts[HttpClientOptions::FORM_PARAMS];
|
||||
}
|
||||
|
||||
if (!empty($opts[HttpClientOptions::AUTH])) {
|
||||
$conf[RequestOptions::AUTH] = $opts[HttpClientOptions::AUTH];
|
||||
}
|
||||
@@ -205,7 +209,11 @@ class HttpClient implements ICanSendHttpRequests
|
||||
{
|
||||
$opts = [];
|
||||
|
||||
$opts[HttpClientOptions::BODY] = $params;
|
||||
if (!is_array($params)) {
|
||||
$opts[HttpClientOptions::BODY] = $params;
|
||||
} else {
|
||||
$opts[HttpClientOptions::FORM_PARAMS] = $params;
|
||||
}
|
||||
|
||||
if (!empty($headers)) {
|
||||
$opts[HttpClientOptions::HEADERS] = $headers;
|
||||
|
||||
@@ -59,9 +59,13 @@ class HttpClientOptions
|
||||
const VERIFY = 'verify';
|
||||
|
||||
/**
|
||||
* body: (mixed) Setting the body for sending data
|
||||
* body: (string) Setting the body for sending data
|
||||
*/
|
||||
const BODY = RequestOptions::BODY;
|
||||
/**
|
||||
* form_params: (array) Associative array of form field names to values
|
||||
*/
|
||||
const FORM_PARAMS = RequestOptions::FORM_PARAMS;
|
||||
/**
|
||||
* auth: (array) Authentication settings for specific requests
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user