Session handler for persistent requests and default parameters
Allows various options to be set as default values, and merges both the options and URL properties together. A base URL can be set for all requests, with all subrequests resolved from this. Base options can be set (including a shared cookie jar), then overridden for individual requests.
| package | Requests |
|---|---|
| subpackage | Session Handler |
__construct(string|null $url= null, array $headers= array(), array $data= array(), array $options= array())
stringnullBase URL for requests
arrayDefault headers for requests
arrayDefault data for requests
arrayDefault options for requests
__get(string $key) : mixed | null
stringProperty key
mixednullProperty value, null if none found__isset(string $key)
stringProperty key
__set(string $key, mixed $value)
stringProperty key
mixedProperty value
__unset(string $key)
stringProperty key
delete($url, $headers= array(), $options= array())
get($url, $headers= array(), $options= array())
head($url, $headers= array(), $options= array())
patch($url, $headers, $data= array(), $options= array())
Note: Unlike \post and \put, $headers is required, as the
specification recommends that should send an ETag
| link | https://tools.ietf.org/html/rfc5789 |
|---|
post($url, $headers= array(), $data= array(), $options= array())
put($url, $headers= array(), $data= array(), $options= array())
request(string $url, array $headers= array(), array|null $data= array(), string $type= \Requests::GET, array $options= array()) : \Requests_Response
This method initiates a request and sends it via a transport before parsing.
| see |
|---|
stringURL to request
arrayExtra headers to send with the request
arraynullData to send either as a query string for GET/HEAD requests, or in the body for POST requests
stringHTTP request type (use Requests constants)
arrayOptions for the request (see {@see Requests::request})
\Requests_Exception |
On invalid URLs (`nonhttp`) |
|---|
\Requests_Responserequest_multiple(array $requests, array $options = array()) : array
merge_request(array $request, boolean $merge_options = true) : array
arrayRequest data (same form as {@see request_multiple})
booleanShould we merge options as well?
arrayRequest data$data : array
array()If both the base data and the per-request data are arrays, the data will be merged before sending the request.
$headers : array
array()$url : string | null
nullURLs will be made absolute using this as the base