fsockopen HTTP transport

package Requests
subpackage Transport

 Methods

Error handler for stream_socket_client()

connect_error_handler(integer $errno, string $errstr) 

Parameters

$errno

integer

Error number (e.g. E_WARNING)

$errstr

string

Error message

Perform a request

request(string $url, array $headers = array(), string|array $data = array(), array $options = array()) : string
inherited_from \Requests_Transport::request()

Parameters

$url

string

URL to request

$headers

array

Associative array of request headers

$data

stringarray

Data to send either as the POST body, or as parameters in the URL for a GET/HEAD

$options

array

Request options, see {@see Requests::response()} for documentation

Exceptions

\Requests_Exception On failure to connect to socket (`fsockopenerror`)
\Requests_Exception On socket timeout (`timeout`)

Returns

stringRaw HTTP result

Send multiple requests simultaneously

request_multiple(array $requests, array $options) : array
inherited_from \Requests_Transport::request_multiple()

Parameters

$requests

array

Request data (array of 'url', 'headers', 'data', 'options') as per {@see Requests_Transport::request}

$options

array

Global options, see {@see Requests::response()} for documentation

Returns

arrayArray of Requests_Response objects (may contain Requests_Exception or string responses as well)

Whether this transport is valid

test($capabilities = array()) : boolean
Static
codeCoverageIgnore
inherited_from \Requests_Transport::test()

Parameters

$capabilities

Returns

booleanTrue if the transport is valid, false otherwise.

Verify the certificate against common name and subject alternative names

verify_certificate_from_context(string $host, resource $context) : boolean

Unfortunately, PHP doesn't check the certificate against the alternative names, leading things like 'https://www.github.com/' to be invalid. Instead

see RFC2818, Section 3.1

Parameters

$host

string

Host name to verify against

$context

resource

Stream context

Exceptions

\Requests_Exception On failure to connect via TLS (`fsockopen.ssl.connect_error`)
\Requests_Exception On not obtaining a match for the host (`fsockopen.ssl.no_match`)

Returns

boolean

Retrieve the encodings we can accept

accept_encoding() : string
Static

Returns

stringAccept-Encoding header value

Format a URL given GET data

format_get(array $url_parts, array|object $data) : string
Static

Parameters

$url_parts

array

$data

arrayobject

Data to build query using, see {@see https://secure.php.net/http_build_query}

Returns

stringURL with data

 Properties

 

Raw HTTP data

$headers : string

Default

''
 

Stream metadata

$info : array

Default

 

$connect_error

$connect_error 

Default

''
 

What's the maximum number of bytes we should keep?

$max_bytes : integer | boolean

Default

false

 Constants

 

Second to microsecond conversion

SECOND_IN_MICROSECONDS = 1000000 : integer