Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PATCH HTTP Verb Support To IClient Interface & its HTTP Client Implementation #43446

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions lib/private/Http/Client/Client.php
Expand Up @@ -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
*
Expand Down
30 changes: 30 additions & 0 deletions lib/public/Http/Client/IClient.php
Expand Up @@ -147,6 +147,36 @@ 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
nickvergessen marked this conversation as resolved.
Show resolved Hide resolved
* @since 29.0.0
*/
public function patch(string $uri, array $options = []): IResponse;

/**
* Sends a DELETE request
* @param string $uri
Expand Down