PHP Класс lithium\net\http\Service

Наследование: extends lithium\core\Object
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$connection lithium\net\Socket The Socket instance used to send Service calls.
$last object Holds the last request and response object

Защищенные свойства (Protected)

Свойство Тип Описание
$_autoConfig array Auto config
$_classes array Fully-name-spaced class references to Service class dependencies.
$_isConnected boolean Defaults to true until a connection attempt fails.
$_responseTypes array Array of closures that return various pieces of information about an HTTP response.

Открытые методы

Метод Описание
__call ( string $method, string $params = [] ) : mixed Magic method to handle other HTTP methods.
__construct ( array $config = [] ) : void Constructor. Initializes a new Service instance with the default HTTP request settings and transport- and format-handling classes.
delete ( string $path = null, array $data = [], array $options = [] ) : string Send DELETE request.
get ( string $path = null, array $data = [], array $options = [] ) : string Send GET request.
head ( string $path = null, array $data = [], array $options = [] ) : string Send HEAD request.
patch ( string $path = null, array $data = [], array $options = [] ) : string Send PATCH request.
post ( string $path = null, array $data = [], array $options = [] ) : string Send POST request.
put ( string $path = null, array $data = [], array $options = [] ) : string Send PUT request.
respondsTo ( string $method, boolean $internal = false ) : boolean Determines if a given method can be called.
send ( string $method, string $path = null, array $data = [], array $options = [] ) : string Send request and return response data. Will open the connection if needed and always close it after sending the request.

Защищенные методы

Метод Описание
_init ( ) : void Initialize connection.
_request ( string $method, string $path, string $data, string $options ) : object Instantiates a request object (usually an instance of http\Request) and tests its properties based on the request type and data to be sent.

Описание методов

__call() публичный Метод

Magic method to handle other HTTP methods.
public __call ( string $method, string $params = [] ) : mixed
$method string
$params string
Результат mixed

__construct() публичный Метод

Constructor. Initializes a new Service instance with the default HTTP request settings and transport- and format-handling classes.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `'persistent'` _boolean_ - `'scheme'` _string_ - `'host'` _string_ - `'port'` _integer_ - `'timeout'` _integer_ - `'auth'` _boolean_ - `'username'` _string_ - `'password'` _string_ - `'encoding'` _string_ - `'socket'` _string_
Результат void

_init() защищенный Метод

Initialize connection.
protected _init ( ) : void
Результат void

_request() защищенный Метод

Instantiates a request object (usually an instance of http\Request) and tests its properties based on the request type and data to be sent.
protected _request ( string $method, string $path, string $data, string $options ) : object
$method string The HTTP method of the request, i.e. `'GET'`, `'HEAD'`, `'OPTIONS'`, etc. Can be passed in upper- or lower-case.
$path string The
$data string
$options string
Результат object Returns an instance of `http\Request`, configured with an HTTP method, query string or POST/PUT/PATCH data, and URL.

delete() публичный Метод

Send DELETE request.
public delete ( string $path = null, array $data = [], array $options = [] ) : string
$path string
$data array
$options array
Результат string

get() публичный Метод

Send GET request.
public get ( string $path = null, array $data = [], array $options = [] ) : string
$path string
$data array
$options array
Результат string

head() публичный Метод

Send HEAD request.
public head ( string $path = null, array $data = [], array $options = [] ) : string
$path string
$data array
$options array
Результат string

patch() публичный Метод

Send PATCH request.
public patch ( string $path = null, array $data = [], array $options = [] ) : string
$path string
$data array
$options array
Результат string

post() публичный Метод

Send POST request.
public post ( string $path = null, array $data = [], array $options = [] ) : string
$path string
$data array
$options array
Результат string

put() публичный Метод

Send PUT request.
public put ( string $path = null, array $data = [], array $options = [] ) : string
$path string
$data array
$options array
Результат string

respondsTo() публичный Метод

Determines if a given method can be called.
public respondsTo ( string $method, boolean $internal = false ) : boolean
$method string Name of the method.
$internal boolean Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`.
Результат boolean Returns `true` if the method can be called, `false` otherwise.

send() публичный Метод

Will automatically authenticate when receiving a 401 HTTP status code then continue retrying sending initial request.
public send ( string $method, string $path = null, array $data = [], array $options = [] ) : string
$method string
$path string
$data array the parameters for the request. For GET/DELETE this is the query string for POST/PUT this is the body
$options array passed to request and socket
Результат string

Описание свойств

$_autoConfig защищенное свойство

Auto config
protected array $_autoConfig
Результат array

$_classes защищенное свойство

Fully-name-spaced class references to Service class dependencies.
protected array $_classes
Результат array

$_isConnected защищенное свойство

Defaults to true until a connection attempt fails.
protected bool $_isConnected
Результат boolean

$_responseTypes защищенное свойство

Array of closures that return various pieces of information about an HTTP response.
protected array $_responseTypes
Результат array

$connection публичное свойство

The Socket instance used to send Service calls.
public lithium\net\Socket $connection
Результат lithium\net\Socket

$last публичное свойство

Holds the last request and response object
public object $last
Результат object