From 00c3a7eb4c8eb7442705dc11d87d7bda3c69bd57 Mon Sep 17 00:00:00 2001 From: Daniel Calviño Sánchez Date: Thu, 14 Jun 2018 21:12:29 +0200 Subject: Fix HTTP client given options being overriden by default options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the array_merge documentation, "If the input arrays have the same string keys, then the later value for that key will overwrite the previous one." Thus, the default options must be the first parameter passed to array_merge. Signed-off-by: Daniel Calviño Sánchez --- lib/private/Http/Client/Client.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/private/Http/Client') diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 0387fcabfaf..03b09bf54b7 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -158,7 +158,7 @@ class Client implements IClient { */ public function get(string $uri, array $options = []): IResponse { $this->setDefaultOptions(); - $response = $this->client->request('get', $uri, array_merge($options, $this->getRequestOptions())); + $response = $this->client->request('get', $uri, array_merge($this->getRequestOptions(), $options)); $isStream = isset($options['stream']) && $options['stream']; return new Response($response, $isStream); } @@ -189,7 +189,7 @@ class Client implements IClient { */ public function head(string $uri, array $options = []): IResponse { $this->setDefaultOptions(); - $response = $this->client->request('head', $uri, array_merge($options, $this->getRequestOptions())); + $response = $this->client->request('head', $uri, array_merge($this->getRequestOptions(), $options)); return new Response($response); } @@ -228,7 +228,7 @@ class Client implements IClient { $options['form_params'] = $options['body']; unset($options['body']); } - $response = $this->client->request('post', $uri, array_merge($options, $this->getRequestOptions())); + $response = $this->client->request('post', $uri, array_merge($this->getRequestOptions(), $options)); return new Response($response); } @@ -263,7 +263,7 @@ class Client implements IClient { */ public function put(string $uri, array $options = []): IResponse { $this->setDefaultOptions(); - $response = $this->client->request('put', $uri, array_merge($options, $this->getRequestOptions())); + $response = $this->client->request('put', $uri, array_merge($this->getRequestOptions(), $options)); return new Response($response); } @@ -298,7 +298,7 @@ class Client implements IClient { */ public function delete(string $uri, array $options = []): IResponse { $this->setDefaultOptions(); - $response = $this->client->request('delete', $uri, array_merge($options, $this->getRequestOptions())); + $response = $this->client->request('delete', $uri, array_merge($this->getRequestOptions(), $options)); return new Response($response); } @@ -334,7 +334,7 @@ class Client implements IClient { */ public function options(string $uri, array $options = []): IResponse { $this->setDefaultOptions(); - $response = $this->client->request('options', $uri, array_merge($options, $this->getRequestOptions())); + $response = $this->client->request('options', $uri, array_merge($this->getRequestOptions(), $options)); return new Response($response); } } -- cgit v1.2.3