Skip to content
Permalink
Browse files

Fixes use_post_method (#241)

* fix use_post_method

* improve fix of use_post_method, correct tests
  • Loading branch information
samsk committed Mar 19, 2020
1 parent b83d799 commit 6ca3b6b338711e5d5e6d5be78357d3144147c848
@@ -324,20 +324,23 @@ protected function request($capability, $options = [], $is_retry = false)
}

$this->debug("Sending HTTP Request for {$url} ({$capability})", $options);

if (array_key_exists('query', $options)) {
$this->last_request_url = $url . '?' . \http_build_query($options['query']);
} else {
$this->last_request_url = $url;
}
$this->last_request_url = $url;

try {
/** @var ResponseInterface $response */
if ($this->configuration->readOption('use_post_method')) {
$this->debug('Using POST method per use_post_method option');
$query = (array_key_exists('query', $options)) ? $options['query'] : null;
$response = $this->client->request('POST', $url, array_merge($options, ['form_params' => $query]));

// do not send query options in url, only in form_params
$local_options = $options;
unset($local_options['query']);
$response = $this->client->request('POST', $url, array_merge($local_options, ['form_params' => $query]));
} else {
if (array_key_exists('query', $options)) {
$this->last_request_url = $url . '?' . \http_build_query($options['query']);
}

$response = $this->client->request('GET', $url, $options);
}
} catch (ClientException $e) {

0 comments on commit 6ca3b6b

Please sign in to comment.
You can’t perform that action at this time.