mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
Merge pull request #59530 from SMillerDev/feat/http/psr-18
feat: Implement PSR-18 ClientInterface in IClient
This commit is contained in:
commit
c2cefcc1c7
2 changed files with 24 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue