From 7c11414c9b3ea1b608bcf88381b237a90af348bd Mon Sep 17 00:00:00 2001 From: jithin-space Date: Thu, 8 Feb 2024 15:50:16 +0530 Subject: [PATCH 1/2] added patch method Signed-off-by: jithin-space --- lib/private/Http/Client/Client.php | 35 ++++++++++++++++++++++++++++++ lib/public/Http/Client/IClient.php | 29 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 3bf43e6c07ec6..4bc276af9aa87 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -338,6 +338,41 @@ public function put(string $uri, array $options = []): IResponse { return new Response($response); } + /** + * 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 * diff --git a/lib/public/Http/Client/IClient.php b/lib/public/Http/Client/IClient.php index fb1760c25f216..90e7654f51d47 100644 --- a/lib/public/Http/Client/IClient.php +++ b/lib/public/Http/Client/IClient.php @@ -147,6 +147,35 @@ public function post(string $uri, array $options = []): IResponse; */ 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 + */ + public function patch(string $uri, array $options = []): IResponse; + /** * Sends a DELETE request * @param string $uri From 987b9846888174259dbc28329defdf6cf56d17d8 Mon Sep 17 00:00:00 2001 From: jithin-space Date: Thu, 14 Mar 2024 12:52:56 +0530 Subject: [PATCH 2/2] added @since 29.0.0 on comment --- lib/public/Http/Client/IClient.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/public/Http/Client/IClient.php b/lib/public/Http/Client/IClient.php index 90e7654f51d47..e3135fc7affbb 100644 --- a/lib/public/Http/Client/IClient.php +++ b/lib/public/Http/Client/IClient.php @@ -173,6 +173,7 @@ public function put(string $uri, array $options = []): IResponse; * '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;