diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-06-14 21:12:29 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-06-14 21:36:04 +0200 |
commit | 00c3a7eb4c8eb7442705dc11d87d7bda3c69bd57 (patch) | |
tree | edcb315d7f0d466c91f07e7bcbc49cdb933cbc97 /lib/private/Http | |
parent | 479e31997f0ecde8d3cf59cc54c5f8ac4b1f80d8 (diff) | |
download | nextcloud-server-00c3a7eb4c8eb7442705dc11d87d7bda3c69bd57.tar.gz nextcloud-server-00c3a7eb4c8eb7442705dc11d87d7bda3c69bd57.zip |
Fix HTTP client given options being overriden by default options
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 <danxuliu@gmail.com>
Diffstat (limited to 'lib/private/Http')
-rw-r--r-- | lib/private/Http/Client/Client.php | 12 |
1 files changed, 6 insertions, 6 deletions
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); } } |