diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-03-16 13:21:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 13:21:13 +0100 |
commit | 836c882b8c5f4cc846e5efee4d6987f3fb3e4712 (patch) | |
tree | ee6ce08e2957ebd5529138f25a7b3f5b049da686 | |
parent | 2c29d0e3ed13bd1626736862a5e7b325400cd7db (diff) | |
parent | 987b9846888174259dbc28329defdf6cf56d17d8 (diff) | |
download | nextcloud-server-836c882b8c5f4cc846e5efee4d6987f3fb3e4712.tar.gz nextcloud-server-836c882b8c5f4cc846e5efee4d6987f3fb3e4712.zip |
Merge pull request #43446 from jithin-space/add-patch-request-to-http-client-interface
-rw-r--r-- | lib/private/Http/Client/Client.php | 35 | ||||
-rw-r--r-- | lib/public/Http/Client/IClient.php | 30 |
2 files changed, 65 insertions, 0 deletions
diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 65784e6cb58..e9e888d7047 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -339,6 +339,41 @@ class Client implements IClient { } /** + * Sends a PATCH request + * + * @param string $uri + * @param array $options Array such as + * 'body' => [ + * 'field' => 'abc', + * 'other_field' => '123', + * 'file_name' => fopen('/path/to/file', 'r'), + * ], + * 'headers' => [ + * 'foo' => 'bar', + * ], + * 'cookies' => [ + * 'foo' => 'bar', + * ], + * 'allow_redirects' => [ + * 'max' => 10, // allow at most 10 redirects. + * 'strict' => true, // use "strict" RFC compliant redirects. + * 'referer' => true, // add a Referer header + * 'protocols' => ['https'] // only allow https URLs + * ], + * 'sink' => '/path/to/file', // save to a file or a stream + * 'verify' => true, // bool or string to CA file + * 'debug' => true, + * 'timeout' => 5, + * @return IResponse + * @throws \Exception If the request could not get completed + */ + public function patch(string $uri, array $options = []): IResponse { + $this->preventLocalAddress($uri, $options); + $response = $this->client->request('patch', $uri, $this->buildRequestOptions($options)); + return new Response($response); + } + + /** * Sends a DELETE request * * @param string $uri diff --git a/lib/public/Http/Client/IClient.php b/lib/public/Http/Client/IClient.php index c6b7cafe73f..9661a9e3829 100644 --- a/lib/public/Http/Client/IClient.php +++ b/lib/public/Http/Client/IClient.php @@ -148,6 +148,36 @@ interface IClient { public function put(string $uri, array $options = []): IResponse; /** + * Sends a PATCH request + * @param string $uri + * @param array $options Array such as + * 'body' => [ + * 'field' => 'abc', + * 'other_field' => '123', + * 'file_name' => fopen('/path/to/file', 'r'), + * ], + * 'headers' => [ + * 'foo' => 'bar', + * ], + * 'cookies' => [ + * 'foo' => 'bar', + * ], + * 'allow_redirects' => [ + * 'max' => 10, // allow at most 10 redirects. + * 'strict' => true, // use "strict" RFC compliant redirects. + * 'referer' => true, // add a Referer header + * 'protocols' => ['https'] // only allow https URLs + * ], + * 'sink' => '/path/to/file', // save to a file or a stream + * 'verify' => true, // bool or string to CA file + * 'debug' => true, + * @return IResponse + * @throws \Exception If the request could not get completed + * @since 29.0.0 + */ + public function patch(string $uri, array $options = []): IResponse; + + /** * Sends a DELETE request * @param string $uri * @param array $options Array such as |