Property | Type | Description | |
---|---|---|---|
$connection | lithium\net\Socket | The Socket instance used to send Service calls. | |
$last | object | Holds the last request and response object |
Property | Type | Description | |
---|---|---|---|
$_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. |
Method | Description | |
---|---|---|
__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. |
Method | Description | |
---|---|---|
_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. |
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_ |
return | void |
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 | |
return | object | Returns an instance of `http\Request`, configured with an HTTP method, query string or POST/PUT/PATCH data, and URL. |
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`. |
return | boolean | Returns `true` if the method can be called, `false` otherwise. |
protected array $_classes | ||
return | array |
protected bool $_isConnected | ||
return | boolean |
protected array $_responseTypes | ||
return | array |
public lithium\net\Socket $connection | ||
return | lithium\net\Socket |