Documentation

HordeClientWrapper
in package
implements ClientInterface

Wrap a PSR-18 HTTP client into a frontend similar to the Horde_Http_Client.

Also expose the PSR-18 interface

Tags
author

Chuck Hagenbuch chuck@horde.org

category

Horde

copyright

2007-2017 Horde LLC

license

http://www.horde.org/licenses/bsd BSD

Interfaces, Classes, Traits and Enums

ClientInterface

Table of Contents

$httpMethodOverride  : bool
$request  : Horde_Http_Request_Base
$request.authenticationScheme  : string
$request.data  : array<string|int, mixed>|string
$request.headers  : array<string|int, mixed>
$request.method  : string
$request.password  : string
$request.proxyAuthenticationScheme  : string
$request.proxyPassword  : string
$request.proxyPort  : int
$request.proxyServer  : string
$request.proxyType  : int
$request.proxyUsername  : string
$request.redirects  : int
$request.timeout  : int
$request.uri  : string|Horde_Url
$request.username  : string
$request.verifyPeer  : bool
$uri  : string|null
A predefined uri for generated requests
$httpMethodOverride  : bool
Use POST instead of PUT and DELETE, sending X-HTTP-Method-Override with the intended method name instead.
$lastRequest  : RequestInterface
The previous HTTP request.
$lastResponse  : Response
The most recent HTTP response.
$requestFactory  : RequestFactoryInterface
$streamFactory  : StreamFactoryInterface
__construct()  : mixed
HordeClientWrapper constructor.
delete()  : Horde_Http_Response_Base
Sends a DELETE request.
get()  : Response
Sends a GET request.
head()  : Horde_Http_Response_Base
Sends a HEAD request.
post()  : Horde_Http_Response_Base
Sends a POST request.
put()  : Horde_Http_Response_Base
Sends a PUT request.
request()  : Response
Builds and sends a HTTP request (H5 style)
sendRequest()  : ResponseInterface
Sends a PSR-7 request and returns a PSR-7 response.

Properties

$request.authenticationScheme write-only

public string $request.authenticationScheme

Authentication method, one of the Horde_Http::AUTH_* constants.

$request.data write-only

public array<string|int, mixed>|string $request.data

POST data fields or POST/PUT data body.

$request.headers write-only

public array<string|int, mixed> $request.headers

Hash with additional request headers.

$request.method write-only

public string $request.method

Default request method if not specified for individual requests.

$request.password write-only

public string $request.password

Authentication password.

$request.proxyAuthenticationScheme write-only

public string $request.proxyAuthenticationScheme

Proxy authentication method, one of the Horde_Http::AUTH_* constants.

$request.proxyPassword write-only

public string $request.proxyPassword

Proxy authentication password.

$request.proxyPort write-only

public int $request.proxyPort

Port number of a proxy server.

$request.proxyServer write-only

public string $request.proxyServer

Host name of a proxy server.

$request.proxyType write-only

public int $request.proxyType

Proxy server type, one of the Horde_Http::PROXY_* constants.

$request.proxyUsername write-only

public string $request.proxyUsername

Proxy authentication user name.

$request.redirects write-only

public int $request.redirects

Maximum number of redirects to follow.

$request.uri write-only

public string|Horde_Url $request.uri

Default URI if not specified for individual requests.

$request.username write-only

public string $request.username

Authentication user name.

$request.verifyPeer write-only

public bool $request.verifyPeer

Verify SSL peer certificates?

$httpMethodOverride

Use POST instead of PUT and DELETE, sending X-HTTP-Method-Override with the intended method name instead.

protected bool $httpMethodOverride = false

Methods

__construct()

HordeClientWrapper constructor.

public __construct(ClientInterface $client, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory[, bool $httpMethodOverride = false ]) : mixed

Use a factory to run this. TODO: Move Client and $httpMethodOverride to an options container; TODO: PHP 8: Use property parameters

Parameters
$client : ClientInterface
$requestFactory : RequestFactoryInterface
$streamFactory : StreamFactoryInterface
$httpMethodOverride : bool = false
Return values
mixed

delete()

Sends a DELETE request.

public delete([string $uri = null ][, array<string|int, mixed> $headers = array() ]) : Horde_Http_Response_Base
Parameters
$uri : string = null

Request URI.

$headers : array<string|int, mixed> = array()

Additional request headers.

Tags
throws
Horde_Http_Exception
Return values
Horde_Http_Response_Base

get()

Sends a GET request.

public get([string $uri = null ][, array<string|int, mixed> $headers = array() ]) : Response
Parameters
$uri : string = null

Request URI.

$headers : array<string|int, mixed> = array()

Additional request headers.

Tags
throws
ClientException
Return values
Response

head()

Sends a HEAD request.

public head([string $uri = null ][, array<string|int, mixed> $headers = array() ]) : Horde_Http_Response_Base
Parameters
$uri : string = null

Request URI.

$headers : array<string|int, mixed> = array()

Additional request headers.

Tags
throws
Horde_Http_Exception
Return values
Horde_Http_Response_Base

post()

Sends a POST request.

public post([string $uri = null ][, array<string|int, mixed>|string $data = null ][, array<string|int, mixed> $headers = array() ]) : Horde_Http_Response_Base
Parameters
$uri : string = null

Request URI.

$data : array<string|int, mixed>|string = null

Data fields or data body.

$headers : array<string|int, mixed> = array()

Additional request headers.

Tags
throws
Horde_Http_Exception
Return values
Horde_Http_Response_Base

put()

Sends a PUT request.

public put([string $uri = null ][, string $data = null ][, array<string|int, mixed> $headers = array() ]) : Horde_Http_Response_Base
Parameters
$uri : string = null

Request URI.

$data : string = null

Data body.

$headers : array<string|int, mixed> = array()

Additional request headers.

Tags
throws
Horde_Http_Exception
Return values
Horde_Http_Response_Base

request()

Builds and sends a HTTP request (H5 style)

public request(string $method[, string|Uri|Horde_Url $uri = null ][, string|array<string|int, mixed> $data = null ][, array<string|int, mixed> $headers = [] ]) : Response
Parameters
$method : string

HTTP request method (GET, PUT, etc.)

$uri : string|Uri|Horde_Url = null

URI to request, if different from $this->uri

$data : string|array<string|int, mixed> = null

Request data. Array of form data that will be encoded automatically, or a raw string.

$headers : array<string|int, mixed> = []

Any headers specific to this request. They will be combined with $this->_headers, and override headers of the same name for this request only.

Tags
throws
ClientException
Return values
Response

sendRequest()

Sends a PSR-7 request and returns a PSR-7 response.

public sendRequest(RequestInterface $request) : ResponseInterface
Parameters
$request : RequestInterface
Tags
throws
ClientExceptionInterface

If an error happens while processing the request.

Return values
ResponseInterface

Search results