October\Rain\Network\Http

Http Network Access is used as a cURL wrapper for the HTTP protocol

Public properties

public string $url

url is the HTTP address to use

public string $method

method the request should use

public array $headers

headers to be sent with the request

public callable $headerCallbackFunc

headerCallbackFunc is a custom function for handling response headers

public string $body

body is the last response body

public string $rawBody

rawBody is the last response body (without headers extracted)

public array $code

code is the last returned HTTP code

public array $info

info is the cURL response information

public array $requestOptions

requestOptions contains cURL Options

public array $requestData

requestData

public array $requestHeaders

requestHeaders

public string $argumentSeparator

argumentSeparator

public string $streamFile

streamFile is the file to use when writing to a file

public string $streamFilter

streamFilter is the filter to apply when writing response to a file

public int $maxRedirects

maxRedirects allowed

Protected properties

protected int $redirectCount

redirectCount is an internal counter

Public methods

public string __toString()

Handy if this object is called directly.

public void auth(string $user, string $pass=NULL)

auth adds authentication to the request

Parameters
  • string $user
  • string $pass

public void data($key, $value=NULL)

data added to the request

Parameters
  • $key
  • $value

public void dataFile($key, $filePath)

dataFile added to the request

Parameters
  • $key
  • $filePath

public static self delete(string $url, array $options=NULL)

delete makes a HTTP DELETE call

Parameters
  • string $url
  • array $options

public static self get(string $url, array $options=NULL)

get makes a HTTP GET call

Parameters
  • string $url
  • array $options

public void getRequestData()

getRequestData returns the request data set

public void header(string $value, $value=NULL)

header added to the request

Parameters
  • string $value
  • $value

public void headerCallback($callback)

headerCallback sets a custom method for handling headers

function header_callback($curl, string $headerLine) {}
Parameters
  • $callback

public static void make(string $url, string $method, callable $options=NULL)

make the object with common properties

Parameters
  • string $url - HTTP request address
  • string $method - Request method (GET, POST, PUT, DELETE, etc)
  • callable $options - Callable helper function to modify the object

public void noRedirect()

noRedirect disables follow location (redirects)

public static void options(string $url, array $options=NULL)

options makes a HTTP OPTIONS call

Parameters
  • string $url
  • array $options

public static self patch(string $url, array $options=NULL)

patch makes a HTTP PATCH call

Parameters
  • string $url
  • array $options

public static self post(string $url, array $options=NULL)

post makes a HTTP POST call

Parameters
  • string $url
  • array $options

public void proxy($type, $host, $port, $username=NULL, $password=NULL)

proxy to use with this request

Parameters
  • $type
  • $host
  • $port
  • $username
  • $password

public static void put(string $url, array $options=NULL)

put makes a HTTP PUT call

Parameters
  • string $url
  • array $options

public void send()

send the HTTP request

public void setOption(string $option, string $value=NULL)

setOption as a single option to the request

Parameters
  • string $option
  • string $value

public void timeout(string $timeout)

timeout for the request

Parameters
  • string $timeout

public void toFile(string $path, string $filter=NULL)

toFile write the response to a file

Parameters
  • string $path - Path to file
  • string $filter - Stream filter as listed in stream_get_filters()

public void verifySSL()

verifySSL enabled for the request

Protected methods

protected void headerToArray($header)

headerToArray turns a header string into an array

Parameters
  • $header