Merge pull request #59530 from SMillerDev/feat/http/psr-18

feat: Implement PSR-18 ClientInterface in IClient
This commit is contained in:
Carl Schwan 2026-04-14 18:11:09 +02:00 committed by GitHub
commit c2cefcc1c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -19,6 +19,8 @@ use OCP\ICertificateManager;
use OCP\IConfig;
use OCP\Security\IRemoteHostValidator;
use OCP\ServerVersion;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use function parse_url;
@ -477,6 +479,11 @@ class Client implements IClient {
return new Response($response, $isStream);
}
public function sendRequest(RequestInterface $request): ResponseInterface {
$this->preventLocalAddress((string)$request->getUri(), []);
return $this->client->sendRequest($request);
}
protected function wrapGuzzlePromise(PromiseInterface $promise): IPromise {
return new GuzzlePromiseAdapter(
$promise,

View file

@ -8,12 +8,16 @@ declare(strict_types=1);
*/
namespace OCP\Http\Client;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Interface IClient
*
* @since 8.1.0
*/
interface IClient {
interface IClient extends ClientInterface {
/**
* Default request timeout for requests
@ -268,6 +272,18 @@ interface IClient {
*/
public function request(string $method, string $uri, array $options = []): IResponse;
/**
* Sends a PSR-7 request and returns a PSR-7 response, part of the PSR-18 interface.
*
* @param RequestInterface $request PSR-7 request interface
*
* @return ResponseInterface PSR-7 response interface
*
* @throws \Psr\Http\Client\ClientExceptionInterface If an error happens while processing the request.
* @since 34.0.0
*/
public function sendRequest(RequestInterface $request): ResponseInterface;
/**
* Sends an asynchronous GET request
* @param string $uri