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()
)
string
null
Base URL for requests
array
Default headers for requests
array
Default data for requests
array
Default options for requests
__get(string $key) : mixed | null
string
Property key
mixed
null
Property value, null if none found__isset(string $key)
string
Property key
__set(string $key, mixed $value)
string
Property key
mixed
Property value
__unset(string $key)
string
Property 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 |
---|
string
URL to request
array
Extra headers to send with the request
array
null
Data to send either as a query string for GET/HEAD requests, or in the body for POST requests
string
HTTP request type (use Requests constants)
array
Options for the request (see {@see Requests::request})
\Requests_Exception |
On invalid URLs (`nonhttp`) |
---|
\Requests_Response
request_multiple(array $requests, array $options = array()
) : array
merge_request(array $request, boolean $merge_options = true
) : array
array
Request data (same form as {@see request_multiple})
boolean
Should we merge options as well?
array
Request 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
null
URLs will be made absolute using this as the base