class Http

HTTP client class.

Methods

__construct( Registry $options = null, TransportInterface $transport = null)

Constructor.

mixed
getOption( string $key)

Get an option from the HTTP client.

setOption( string $key, mixed $value)

Set an option for the HTTP client.

options( string $url, array $headers = null, integer $timeout = null)

Method to send the OPTIONS command to the server.

head( string $url, array $headers = null, integer $timeout = null)

Method to send the HEAD command to the server.

get( string $url, array $headers = null, integer $timeout = null)

Method to send the GET command to the server.

post( string $url, mixed $data, array $headers = null, integer $timeout = null)

Method to send the POST command to the server.

put( string $url, mixed $data, array $headers = null, integer $timeout = null)

Method to send the PUT command to the server.

delete( string $url, array $headers = null, integer $timeout = null)

Method to send the DELETE command to the server.

trace( string $url, array $headers = null, integer $timeout = null)

Method to send the TRACE command to the server.

patch( string $url, mixed $data, array $headers = null, integer $timeout = null)

Method to send the PATCH command to the server.

Details

__construct( Registry $options = null, TransportInterface $transport = null)

Constructor.

Parameters

Registry $options Client options object. If the registry contains any headers.* elements, these will be added to the request headers.
TransportInterface $transport The HTTP transport object.

mixed getOption( string $key)

Get an option from the HTTP client.

Parameters

string $key The name of the option to get.

Return Value

mixed The option value.

Http setOption( string $key, mixed $value)

Set an option for the HTTP client.

Parameters

string $key The name of the option to set.
mixed $value The option value to set.

Return Value

Http This object for method chaining.

Response options( string $url, array $headers = null, integer $timeout = null)

Method to send the OPTIONS command to the server.

Parameters

string $url Path to the resource.
array $headers An array of name-value pairs to include in the header of the request.
integer $timeout Read timeout in seconds.

Return Value

Response

Response head( string $url, array $headers = null, integer $timeout = null)

Method to send the HEAD command to the server.

Parameters

string $url Path to the resource.
array $headers An array of name-value pairs to include in the header of the request.
integer $timeout Read timeout in seconds.

Return Value

Response

Response get( string $url, array $headers = null, integer $timeout = null)

Method to send the GET command to the server.

Parameters

string $url Path to the resource.
array $headers An array of name-value pairs to include in the header of the request.
integer $timeout Read timeout in seconds.

Return Value

Response

Response post( string $url, mixed $data, array $headers = null, integer $timeout = null)

Method to send the POST command to the server.

Parameters

string $url Path to the resource.
mixed $data Either an associative array or a string to be sent with the request.
array $headers An array of name-value pairs to include in the header of the request
integer $timeout Read timeout in seconds.

Return Value

Response

Response put( string $url, mixed $data, array $headers = null, integer $timeout = null)

Method to send the PUT command to the server.

Parameters

string $url Path to the resource.
mixed $data Either an associative array or a string to be sent with the request.
array $headers An array of name-value pairs to include in the header of the request.
integer $timeout Read timeout in seconds.

Return Value

Response

Response delete( string $url, array $headers = null, integer $timeout = null)

Method to send the DELETE command to the server.

Parameters

string $url Path to the resource.
array $headers An array of name-value pairs to include in the header of the request.
integer $timeout Read timeout in seconds.

Return Value

Response

Response trace( string $url, array $headers = null, integer $timeout = null)

Method to send the TRACE command to the server.

Parameters

string $url Path to the resource.
array $headers An array of name-value pairs to include in the header of the request.
integer $timeout Read timeout in seconds.

Return Value

Response

Response patch( string $url, mixed $data, array $headers = null, integer $timeout = null)

Method to send the PATCH command to the server.

Parameters

string $url Path to the resource.
mixed $data Either an associative array or a string to be sent with the request.
array $headers An array of name-value pairs to include in the header of the request.
integer $timeout Read timeout in seconds.

Return Value

Response