Open Journal Systems  3.3.0
Guzzle\Http\Client Class Reference
Inheritance diagram for Guzzle\Http\Client:
Guzzle\Common\AbstractHasDispatcher Guzzle\Http\ClientInterface Guzzle\Common\HasDispatcherInterface Guzzle\Common\HasDispatcherInterface Guzzle\Service\Client Guzzle\Tests\Service\Mock\MockClient

Public Member Functions

 __construct ($baseUrl='', $config=null)
 
 createRequest ($method='GET', $uri=null, $headers=null, $body=null, array $options=array())
 
 delete ($uri=null, $headers=null, $body=null, array $options=array())
 
 get ($uri=null, $headers=null, $options=array())
 
 getBaseUrl ($expand=true)
 
 getConfig ($key=false)
 
 getCurlMulti ()
 
 getDefaultHeaders ()
 
 getDefaultOption ($keyOrPath)
 
 getDefaultUserAgent ()
 
 head ($uri=null, $headers=null, array $options=array())
 
 options ($uri=null, array $options=array())
 
 patch ($uri=null, $headers=null, $body=null, array $options=array())
 
 post ($uri=null, $headers=null, $postBody=null, array $options=array())
 
 preparePharCacert ($md5Check=true)
 
 put ($uri=null, $headers=null, $body=null, array $options=array())
 
 send ($requests)
 
 setBaseUrl ($url)
 
 setConfig ($config)
 
 setCurlMulti (CurlMultiInterface $curlMulti)
 
 setDefaultHeaders ($headers)
 
 setDefaultOption ($keyOrPath, $value)
 
 setRequestFactory (RequestFactoryInterface $factory)
 
 setSslVerification ($certificateAuthority=true, $verifyPeer=true, $verifyHost=2)
 
 setUriTemplate (UriTemplateInterface $uriTemplate)
 
 setUserAgent ($userAgent, $includeDefault=false)
 
- Public Member Functions inherited from Guzzle\Common\AbstractHasDispatcher
 addSubscriber (EventSubscriberInterface $subscriber)
 
 dispatch ($eventName, array $context=array())
 
 getEventDispatcher ()
 
 setEventDispatcher (EventDispatcherInterface $eventDispatcher)
 

Static Public Member Functions

static extractPharCacert ($pharCacertPath)
 
static getAllEvents ()
 

Data Fields

const CURL_OPTIONS = 'curl.options'
 
const DEFAULT_SELECT_TIMEOUT = 1.0
 
const DISABLE_REDIRECTS = RedirectPlugin::DISABLE
 
const MAX_HANDLES = 3
 
const REQUEST_OPTIONS = 'request.options'
 
const REQUEST_PARAMS = 'request.params'
 
const SSL_CERT_AUTHORITY = 'ssl.certificate_authority'
 
- Data Fields inherited from Guzzle\Http\ClientInterface
const CREATE_REQUEST = 'client.create_request'
 
const HTTP_DATE = 'D, d M Y H:i:s \G\M\T'
 

Protected Member Functions

 expandTemplate ($template, array $variables=null)
 
 getUriTemplate ()
 
 initSsl ()
 
 prepareRequest (RequestInterface $request, array $options=array())
 
 sendMultiple (array $requests)
 

Protected Attributes

 $defaultHeaders
 
 $requestFactory
 
 $userAgent
 
- Protected Attributes inherited from Guzzle\Common\AbstractHasDispatcher
 $eventDispatcher
 

Detailed Description

HTTP client

Definition at line 24 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Http\Client::__construct (   $baseUrl = '',
  $config = null 
)

Member Function Documentation

◆ createRequest()

Guzzle\Http\Client::createRequest (   $method = 'GET',
  $uri = null,
  $headers = null,
  $body = null,
array  $options = array() 
)

Create and return a new {

See also
RequestInterface} configured for the client.

Use an absolute path to override the base path of the client, or a relative path to append to the base path of the client. The URI can contain the query string as well. Use an array to provide a URI template and additional variables to use in the URI template expansion.

Parameters
string$methodHTTP method. Defaults to GET
string | array$uriResource URI.
array | Collection$headersHTTP headers
string | resource | array | EntityBodyInterface$bodyEntity body of request (POST/PUT) or response (GET)
array$optionsArray of options to apply to the request
Returns
RequestInterface
Exceptions
InvalidArgumentExceptionif a URI array is passed that does not contain exactly two elements: the URI followed by template variables

Implements Guzzle\Http\ClientInterface.

Definition at line 193 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\expandTemplate(), Guzzle\Http\Url\factory(), Guzzle\Http\Client\getBaseUrl(), and Guzzle\Http\Client\prepareRequest().

Referenced by Guzzle\Http\Client\delete(), Guzzle\Http\Client\get(), Guzzle\Http\Client\head(), Guzzle\Http\Client\options(), Guzzle\Http\Client\patch(), Guzzle\Http\Client\post(), and Guzzle\Http\Client\put().

◆ delete()

Guzzle\Http\Client::delete (   $uri = null,
  $headers = null,
  $body = null,
array  $options = array() 
)

Create a DELETE request for the client

Parameters
string | array$uriResource URI
array | Collection$headersHTTP headers
string | resource | EntityBodyInterface$bodyBody to send in the request
array$optionsOptions to apply to the request
Returns
EntityEnclosingRequestInterface
See also
Guzzle\Http\ClientInterface::createRequest()

Implements Guzzle\Http\ClientInterface.

Definition at line 272 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\createRequest().

◆ expandTemplate()

Guzzle\Http\Client::expandTemplate (   $template,
array  $variables = null 
)
protected

Expand a URI template while merging client config settings into the template variables

Parameters
string$templateTemplate to expand
array$variablesVariables to inject
Returns
string

Definition at line 370 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\getConfig(), and Guzzle\Http\Client\getUriTemplate().

Referenced by Guzzle\Http\Client\createRequest(), and Guzzle\Http\Client\getBaseUrl().

◆ extractPharCacert()

static Guzzle\Http\Client::extractPharCacert (   $pharCacertPath)
static

Copies the phar cacert from a phar into the temp directory.

Parameters
string$pharCacertPathPath to the phar cacert. For example: 'phar://aws.phar/Guzzle/Http/Resources/cacert.pem'
Returns
string Returns the path to the extracted cacert file.
Exceptions

Definition at line 522 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Referenced by Guzzle\Http\Client\initSsl().

◆ get()

Guzzle\Http\Client::get (   $uri = null,
  $headers = null,
  $options = array() 
)

Create a GET request for the client

Parameters
string | array$uriResource URI
array | Collection$headersHTTP headers
array$optionsOptions to apply to the request. For BC compatibility, you can also pass a string to tell Guzzle to download the body of the response to a particular location. Use the 'body' option instead for forward compatibility.
Returns
RequestInterface
See also
Guzzle\Http\ClientInterface::createRequest()

Implements Guzzle\Http\ClientInterface.

Definition at line 259 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\createRequest().

◆ getAllEvents()

static Guzzle\Http\Client::getAllEvents ( )
static

Get a list of all of the events emitted from the class

Returns
array

Reimplemented from Guzzle\Common\AbstractHasDispatcher.

Reimplemented in Guzzle\Service\Client.

Definition at line 78 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Referenced by Guzzle\Tests\Http\ClientTest\testDescribesEvents().

◆ getBaseUrl()

Guzzle\Http\Client::getBaseUrl (   $expand = true)

Get the client's base URL as either an expanded or raw URI template

Parameters
bool$expandSet to FALSE to get the raw base URL without URI template expansion
Returns
string|null

Implements Guzzle\Http\ClientInterface.

Definition at line 225 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\expandTemplate().

Referenced by Guzzle\Http\Client\createRequest().

◆ getConfig()

Guzzle\Http\Client::getConfig (   $key = false)
final

Get a configuration setting or all of the configuration settings. The Collection result of this method can be modified to change the configuration settings of a client.

A client should honor the following special values:

  • request.options: Associative array of default RequestFactory options to apply to each request
  • request.params: Associative array of request parameters (data values) to apply to each request
  • curl.options: Associative array of cURL configuration settings to apply to each request
  • ssl.certificate_authority: Path a CAINFO, CAPATH, true to use strict defaults, or false to disable verification
  • redirect.disable: Set to true to disable redirects
Parameters
bool | string$keyConfiguration value to retrieve. Set to FALSE to retrieve all values of the client. The object return can be modified, and modifications will affect the client's config.
Returns
mixed|Collection
See also
\Guzzle\Http\Message\RequestFactoryInterface::applyOptions for a full list of request.options options

Implements Guzzle\Http\ClientInterface.

Definition at line 120 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Referenced by Guzzle\Http\Client\expandTemplate(), Guzzle\Service\Client\getCommand(), and Guzzle\Http\Client\getCurlMulti().

◆ getCurlMulti()

Guzzle\Http\Client::getCurlMulti ( )
Returns
CurlMultiInterface|CurlMultiProxy

Definition at line 329 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\getConfig().

Referenced by Guzzle\Http\Client\send(), and Guzzle\Http\Client\sendMultiple().

◆ getDefaultHeaders()

Guzzle\Http\Client::getDefaultHeaders ( )

◆ getDefaultOption()

Guzzle\Http\Client::getDefaultOption (   $keyOrPath)

Retrieve a default request option from the client

Parameters
string$keyOrPathrequest.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)
Returns
mixed|null

Definition at line 148 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

◆ getDefaultUserAgent()

Guzzle\Http\Client::getDefaultUserAgent ( )

Get the default User-Agent string to use with Guzzle

Returns
string

Definition at line 252 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Curl\CurlVersion\getInstance(), and Guzzle\Common\Version\VERSION.

Referenced by Guzzle\Http\Client\__construct(), and Guzzle\Http\Client\setUserAgent().

◆ getUriTemplate()

Guzzle\Http\Client::getUriTemplate ( )
protected

Get the URI template expander used by the client

Returns
UriTemplateInterface

Definition at line 385 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Parser\ParserRegistry\getInstance().

Referenced by Guzzle\Http\Client\expandTemplate().

◆ head()

Guzzle\Http\Client::head (   $uri = null,
  $headers = null,
array  $options = array() 
)

Create a HEAD request for the client

Parameters
string | array$uriResource URI
array | Collection$headersHTTP headers
array$optionsOptions to apply to the request
Returns
RequestInterface
See also
Guzzle\Http\ClientInterface::createRequest()

Implements Guzzle\Http\ClientInterface.

Definition at line 267 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\createRequest().

◆ initSsl()

Guzzle\Http\Client::initSsl ( )
protected

◆ options()

Guzzle\Http\Client::options (   $uri = null,
array  $options = array() 
)

Create an OPTIONS request for the client

Parameters
string | array$uriResource URI
array$optionsOptions to apply to the request
Returns
RequestInterface
See also
Guzzle\Http\ClientInterface::createRequest()

Implements Guzzle\Http\ClientInterface.

Definition at line 292 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\createRequest().

◆ patch()

Guzzle\Http\Client::patch (   $uri = null,
  $headers = null,
  $body = null,
array  $options = array() 
)

Create a PATCH request for the client

Parameters
string | array$uriResource URI
array | Collection$headersHTTP headers
string | resource | EntityBodyInterface$bodyBody to send in the request
array$optionsOptions to apply to the request
Returns
EntityEnclosingRequestInterface
See also
Guzzle\Http\ClientInterface::createRequest()

Implements Guzzle\Http\ClientInterface.

Definition at line 282 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\createRequest().

◆ post()

Guzzle\Http\Client::post (   $uri = null,
  $headers = null,
  $postBody = null,
array  $options = array() 
)

Create a POST request for the client

Parameters
string | array$uriResource URI
array | Collection$headersHTTP headers
array | Collection | string | EntityBodyInterface$postBodyPOST body. Can be a string, EntityBody, or associative array of POST fields to send in the body of the request. Prefix a value in the array with the @ symbol to reference a file.
array$optionsOptions to apply to the request
Returns
EntityEnclosingRequestInterface
See also
Guzzle\Http\ClientInterface::createRequest()

Implements Guzzle\Http\ClientInterface.

Definition at line 287 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\createRequest().

◆ preparePharCacert()

Guzzle\Http\Client::preparePharCacert (   $md5Check = true)

◆ prepareRequest()

Guzzle\Http\Client::prepareRequest ( RequestInterface  $request,
array  $options = array() 
)
protected

◆ put()

Guzzle\Http\Client::put (   $uri = null,
  $headers = null,
  $body = null,
array  $options = array() 
)

Create a PUT request for the client

Parameters
string | array$uriResource URI
array | Collection$headersHTTP headers
string | resource | EntityBodyInterface$bodyBody to send in the request
array$optionsOptions to apply to the request
Returns
EntityEnclosingRequestInterface
See also
Guzzle\Http\ClientInterface::createRequest()

Implements Guzzle\Http\ClientInterface.

Definition at line 277 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\createRequest().

◆ send()

Guzzle\Http\Client::send (   $requests)

Sends a single request or an array of requests in parallel

Parameters
array | RequestInterface$requestsOne or more RequestInterface objects to send
Returns
\Guzzle\Http\Message\Response|array Returns a single Response or an array of Response objects

Implements Guzzle\Http\ClientInterface.

Definition at line 297 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\getCurlMulti(), Guzzle\Common\Exception\ExceptionCollection\getFirst(), and Guzzle\Http\Client\sendMultiple().

Referenced by Guzzle\Service\Client\execute(), and Guzzle\Service\Client\executeMultiple().

◆ sendMultiple()

Guzzle\Http\Client::sendMultiple ( array  $requests)
protected

Send multiple requests in parallel

Parameters
array$requestsArray of RequestInterface objects
Returns
array Returns an array of Response objects

Definition at line 401 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\getCurlMulti().

Referenced by Guzzle\Http\Client\send().

◆ setBaseUrl()

Guzzle\Http\Client::setBaseUrl (   $url)

Set the base URL of the client

Parameters
string$urlThe base service endpoint URL of the webservice
Returns
self

Implements Guzzle\Http\ClientInterface.

Definition at line 230 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Referenced by Guzzle\Http\Client\__construct(), and Guzzle\Service\Client\setDescription().

◆ setConfig()

Guzzle\Http\Client::setConfig (   $config)
final

Set the configuration object to use with the client

Parameters
array | Collection$configParameters that define how the client behaves
Returns
self

Implements Guzzle\Http\ClientInterface.

Definition at line 107 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Referenced by Guzzle\Http\Client\__construct().

◆ setCurlMulti()

Guzzle\Http\Client::setCurlMulti ( CurlMultiInterface  $curlMulti)

Set a curl multi object to be used internally by the client for transferring requests.

Parameters
CurlMultiInterface$curlMultiMulti object
Returns
self

Definition at line 319 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

◆ setDefaultHeaders()

Guzzle\Http\Client::setDefaultHeaders (   $headers)

◆ setDefaultOption()

Guzzle\Http\Client::setDefaultOption (   $keyOrPath,
  $value 
)

Set a default request option on the client that will be used as a default for each request

Parameters
string$keyOrPathrequest.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)
mixed$valueValue to set
Returns
$this

Definition at line 133 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

◆ setRequestFactory()

Guzzle\Http\Client::setRequestFactory ( RequestFactoryInterface  $factory)

◆ setSslVerification()

Guzzle\Http\Client::setSslVerification (   $certificateAuthority = true,
  $verifyPeer = true,
  $verifyHost = 2 
)
final

Set SSL verification options.

Setting $certificateAuthority to TRUE will result in the bundled cacert.pem being used to verify against the remote host.

Alternate certificates to verify against can be specified with the $certificateAuthority option set to the full path to a certificate file, or the path to a directory containing certificates.

Setting $certificateAuthority to FALSE will turn off peer verification, unset the bundled cacert.pem, and disable host verification. Please don't do this unless you really know what you're doing, and why you're doing it.

Parameters
string | bool$certificateAuthoritybool, file path, or directory path
bool$verifyPeerFALSE to stop from verifying the peer's certificate.
int$verifyHostSet to 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided.
Returns
self

Implements Guzzle\Http\ClientInterface.

Definition at line 155 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\CURL_OPTIONS.

Referenced by Guzzle\Http\Client\initSsl().

◆ setUriTemplate()

Guzzle\Http\Client::setUriTemplate ( UriTemplateInterface  $uriTemplate)

Set the URI template expander to use with the client

Parameters
UriTemplateInterface$uriTemplateURI template expander
Returns
self

Definition at line 355 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

◆ setUserAgent()

Guzzle\Http\Client::setUserAgent (   $userAgent,
  $includeDefault = false 
)

Set the User-Agent header to be used on all requests from the client

Parameters
string$userAgentUser agent string
bool$includeDefaultSet to true to prepend the value to Guzzle's default user agent string
Returns
self

Implements Guzzle\Http\ClientInterface.

Definition at line 237 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

References Guzzle\Http\Client\$userAgent, and Guzzle\Http\Client\getDefaultUserAgent().

Field Documentation

◆ $defaultHeaders

Collection Guzzle\Http\Client::$defaultHeaders
protected

Default HTTP headers to set on each request

Definition at line 40 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Referenced by Guzzle\Http\Client\getDefaultHeaders().

◆ $requestFactory

RequestFactoryInterface Guzzle\Http\Client::$requestFactory
protected

Request factory used by the client

Definition at line 76 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

◆ $userAgent

string Guzzle\Http\Client::$userAgent
protected

The user agent string to set on each request

Definition at line 46 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

Referenced by Guzzle\Http\Client\setUserAgent().

◆ CURL_OPTIONS

const Guzzle\Http\Client::CURL_OPTIONS = 'curl.options'

◆ DEFAULT_SELECT_TIMEOUT

const Guzzle\Http\Client::DEFAULT_SELECT_TIMEOUT = 1.0

◆ DISABLE_REDIRECTS

const Guzzle\Http\Client::DISABLE_REDIRECTS = RedirectPlugin::DISABLE

◆ MAX_HANDLES

const Guzzle\Http\Client::MAX_HANDLES = 3

◆ REQUEST_OPTIONS

const Guzzle\Http\Client::REQUEST_OPTIONS = 'request.options'

◆ REQUEST_PARAMS

const Guzzle\Http\Client::REQUEST_PARAMS = 'request.params'
Deprecated:
Use [request.options][params]

Definition at line 27 of file lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php.

◆ SSL_CERT_AUTHORITY

const Guzzle\Http\Client::SSL_CERT_AUTHORITY = 'ssl.certificate_authority'

The documentation for this class was generated from the following file: