October\Rain\Network\Http

Source: ~/vendor/october/rain/src/Network/Http.php

HTTP Network Access

Used as a cURL wrapper for the HTTP protocol.

Public properties

public string $url

The HTTP address to use.

public string $method

The method the request should use.

public array $headers

The headers to be sent with the request.

public string $body

The last response body.

public string $rawBody

The last response body (without headers extracted).

public array $code

The last returned HTTP code.

public array $info

The cURL response information.

public array $requestOptions

cURL Options.

public array $requestData

Request data.

public array $requestHeaders

Request headers.

public string $argumentSeparator

Argument separator.

public string $streamFile

If writing response to a file, which file to use.

public string $streamFilter

If writing response to a file, which write filter to apply.

public int $maxRedirects

The maximum redirects allowed.

Protected properties

protected int $redirectCount

Internal counter

Public methods

public string __toString()

Handy if this object is called directly.

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

Adds authentication to the comms.

Parameters
  • string $user
  • string $pass

public self data(string $value, $value=NULL)

Add a data to the request.

Parameters
  • string $value
  • $value

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

Make a HTTP DELETE call.

Parameters
  • string $url
  • array $options

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

Make a HTTP GET call.

Parameters
  • string $url
  • array $options

public string getRequestData()

Return the request data set.

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

Add a header to the request.

Parameters
  • string $value
  • $value

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()

Disable follow location (redirects)

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

Make a HTTP OPTIONS call.

Parameters
  • string $url
  • array $options

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

Make a HTTP PATCH call.

Parameters
  • string $url
  • array $options

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

Make a HTTP POST call.

Parameters
  • string $url
  • array $options

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

Sets a proxy to use with this request

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

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

Make a HTTP PUT call.

Parameters
  • string $url
  • array $options

public string send()

Execute the HTTP request.

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

Add a single option to the request.

Parameters
  • string $option
  • string $value

public self timeout(string $timeout)

Sets the request timeout.

Parameters
  • string $timeout

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

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()

Enable SSL verification

Protected methods

protected array headerToArray(string $header)

Turn a header string into an array.

Parameters
  • string $header