Http
in package
HTTP Network Access
Used as a cURL wrapper for the HTTP protocol.
Tags
Table of Contents
- METHOD_DELETE = 'DELETE'
- METHOD_GET = 'GET'
- METHOD_OPTIONS = 'OPTIONS'
- METHOD_PATCH = 'PATCH'
- METHOD_POST = 'POST'
- METHOD_PUT = 'PUT'
- $argumentSeparator : string
- $body : string
- $code : array<string|int, mixed>
- $headers : array<string|int, mixed>
- $info : array<string|int, mixed>
- $maxRedirects : int
- $method : string
- $rawBody : string
- $requestData : array<string|int, mixed>
- $requestHeaders : array<string|int, mixed>
- $requestOptions : array<string|int, mixed>
- $streamFile : string
- $streamFilter : string
- $url : string
- $redirectCount : int
- __toString() : string
- Handy if this object is called directly.
- auth() : self
- Adds authentication to the comms.
- data() : self
- Add a data to the request.
- delete() : self
- Make a HTTP DELETE call.
- get() : self
- Make a HTTP GET call.
- getRequestData() : string
- Return the request data set.
- header() : self
- Add a header to the request.
- make() : mixed
- Make the object with common properties
- noRedirect() : mixed
- Disable follow location (redirects)
- options() : self
- Make a HTTP OPTIONS call.
- patch() : self
- Make a HTTP PATCH call.
- post() : self
- Make a HTTP POST call.
- proxy() : mixed
- Sets a proxy to use with this request
- put() : self
- Make a HTTP PUT call.
- send() : string
- Execute the HTTP request.
- setOption() : self
- Add a single option to the request.
- timeout() : self
- Sets the request timeout.
- toFile() : self
- Write the response to a file
- verifySSL() : mixed
- Enable SSL verification
- headerToArray() : array<string|int, mixed>
- Turn a header string into an array.
Constants
METHOD_DELETE
public
mixed
METHOD_DELETE
= 'DELETE'
METHOD_GET
public
mixed
METHOD_GET
= 'GET'
METHOD_OPTIONS
public
mixed
METHOD_OPTIONS
= 'OPTIONS'
METHOD_PATCH
public
mixed
METHOD_PATCH
= 'PATCH'
METHOD_POST
public
mixed
METHOD_POST
= 'POST'
METHOD_PUT
public
mixed
METHOD_PUT
= 'PUT'
Properties
$argumentSeparator
public
string
$argumentSeparator
= '&'
Argument separator.
$body
public
string
$body
= ''
The last response body.
$code
public
array<string|int, mixed>
$code
The last returned HTTP code.
$headers
public
array<string|int, mixed>
$headers
= []
The headers to be sent with the request.
$info
public
array<string|int, mixed>
$info
The cURL response information.
$maxRedirects
public
int
$maxRedirects
= 10
The maximum redirects allowed.
$method
public
string
$method
The method the request should use.
$rawBody
public
string
$rawBody
= ''
The last response body (without headers extracted).
$requestData
public
array<string|int, mixed>
$requestData
Request data.
$requestHeaders
public
array<string|int, mixed>
$requestHeaders
Request headers.
$requestOptions
public
array<string|int, mixed>
$requestOptions
cURL Options.
$streamFile
public
string
$streamFile
If writing response to a file, which file to use.
$streamFilter
public
string
$streamFilter
If writing response to a file, which write filter to apply.
$url
public
string
$url
The HTTP address to use.
$redirectCount
protected
int
$redirectCount
= null
Internal counter
Methods
__toString()
Handy if this object is called directly.
public
__toString() : string
Return values
string —The last response.
auth()
Adds authentication to the comms.
public
auth(string $user[, string $pass = null ]) : self
Parameters
- $user : string
- $pass : string = null
Return values
self —data()
Add a data to the request.
public
data(mixed $key[, string $value = null ]) : self
Parameters
- $key : mixed
- $value : string = null
Return values
self —delete()
Make a HTTP DELETE call.
public
static delete(string $url[, callable $options = null ]) : self
Parameters
- $url : string
- $options : callable = null
Return values
self —get()
Make a HTTP GET call.
public
static get(string $url[, callable $options = null ]) : self
Parameters
- $url : string
- $options : callable = null
Return values
self —getRequestData()
Return the request data set.
public
getRequestData() : string
Return values
string —header()
Add a header to the request.
public
header(mixed $key[, string $value = null ]) : self
Parameters
- $key : mixed
- $value : string = null
Return values
self —make()
Make the object with common properties
public
static make(string $url, string $method[, callable $options = null ]) : mixed
Parameters
- $url : string
-
HTTP request address
- $method : string
-
Request method (GET, POST, PUT, DELETE, etc)
- $options : callable = null
-
Callable helper function to modify the object
Return values
mixed —noRedirect()
Disable follow location (redirects)
public
noRedirect() : mixed
Return values
mixed —options()
Make a HTTP OPTIONS call.
public
static options(string $url[, callable $options = null ]) : self
Parameters
- $url : string
- $options : callable = null
Return values
self —patch()
Make a HTTP PATCH call.
public
static patch(string $url[, callable $options = null ]) : self
Parameters
- $url : string
- $options : callable = null
Return values
self —post()
Make a HTTP POST call.
public
static post(string $url[, callable $options = null ]) : self
Parameters
- $url : string
- $options : callable = null
Return values
self —proxy()
Sets a proxy to use with this request
public
proxy(mixed $type, mixed $host, mixed $port[, mixed $username = null ][, mixed $password = null ]) : mixed
Parameters
- $type : mixed
- $host : mixed
- $port : mixed
- $username : mixed = null
- $password : mixed = null
Return values
mixed —put()
Make a HTTP PUT call.
public
static put(string $url[, callable $options = null ]) : self
Parameters
- $url : string
- $options : callable = null
Return values
self —send()
Execute the HTTP request.
public
send() : string
Return values
string —response body
setOption()
Add a single option to the request.
public
setOption(string $option[, string $value = null ]) : self
Parameters
- $option : string
- $value : string = null
Return values
self —timeout()
Sets the request timeout.
public
timeout(string $timeout) : self
Parameters
- $timeout : string
Return values
self —toFile()
Write the response to a file
public
toFile(string $path[, string $filter = null ]) : self
Parameters
- $path : string
-
Path to file
- $filter : string = null
-
Stream filter as listed in stream_get_filters()
Return values
self —verifySSL()
Enable SSL verification
public
verifySSL() : mixed
Return values
mixed —headerToArray()
Turn a header string into an array.
protected
headerToArray(string $header) : array<string|int, mixed>
Parameters
- $header : string