Fsockopen
in package
implements
Transport
fsockopen HTTP transport
Table of Contents
Interfaces
- Transport
- Base HTTP transport
Constants
- SECOND_IN_MICROSECONDS = 1000000
- Second to microsecond conversion
Properties
- $headers : string
- Raw HTTP data
- $info : array<string|int, mixed>
- Stream metadata
- $connect_error : string
- Cache for received connection errors.
- $max_bytes : int|bool
- What's the maximum number of bytes we should keep?
Methods
- connect_error_handler() : mixed
- Error handler for stream_socket_client()
- request() : string
- Perform a request
- request_multiple() : array<string|int, mixed>
- Send multiple requests simultaneously
- test() : bool
- Self-test whether the transport can be used.
- verify_certificate_from_context() : bool
- Verify the certificate against common name and subject alternative names
- accept_encoding() : string
- Retrieve the encodings we can accept
- format_get() : string
- Format a URL given GET data
Constants
SECOND_IN_MICROSECONDS
Second to microsecond conversion
public
int
SECOND_IN_MICROSECONDS
= 1000000
Properties
$headers
Raw HTTP data
public
string
$headers
= ''
$info
Stream metadata
public
array<string|int, mixed>
$info
$connect_error
Cache for received connection errors.
private
string
$connect_error
= ''
$max_bytes
What's the maximum number of bytes we should keep?
private
int|bool
$max_bytes
= false
Byte count, or false if no limit.
Methods
connect_error_handler()
Error handler for stream_socket_client()
public
connect_error_handler(int $errno, string $errstr) : mixed
Parameters
- $errno : int
-
Error number (e.g. E_WARNING)
- $errstr : string
-
Error message
request()
Perform a request
public
request(string|Stringable $url[, array<string|int, mixed> $headers = [] ][, string|array<string|int, mixed> $data = [] ][, array<string|int, mixed> $options = [] ]) : string
Parameters
- $url : string|Stringable
-
URL to request
- $headers : array<string|int, mixed> = []
-
Associative array of request headers
- $data : string|array<string|int, mixed> = []
-
Data to send either as the POST body, or as parameters in the URL for a GET/HEAD
- $options : array<string|int, mixed> = []
-
Request options, see Requests::response() for documentation
Tags
Return values
string —Raw HTTP result
request_multiple()
Send multiple requests simultaneously
public
request_multiple(array<string|int, mixed> $requests, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $requests : array<string|int, mixed>
-
Request data (array of 'url', 'headers', 'data', 'options') as per Transport::request()
- $options : array<string|int, mixed>
-
Global options, see Requests::response() for documentation
Tags
Return values
array<string|int, mixed> —Array of \WpOrg\Requests\Response objects (may contain \WpOrg\Requests\Exception or string responses as well)
test()
Self-test whether the transport can be used.
public
static test([array<string, bool> $capabilities = [] ]) : bool
The available capabilities to test for can be found in Capability.
Parameters
- $capabilities : array<string, bool> = []
-
Optional. Associative array of capabilities to test against, i.e.
['<capability>' => true]
.
Tags
Return values
bool —Whether the transport can be used.
verify_certificate_from_context()
Verify the certificate against common name and subject alternative names
public
verify_certificate_from_context(string $host, resource $context) : bool
Unfortunately, PHP doesn't check the certificate against the alternative names, leading things like 'https://www.github.com/' to be invalid. Instead
Parameters
- $host : string
-
Host name to verify against
- $context : resource
-
Stream context
Tags
Return values
boolaccept_encoding()
Retrieve the encodings we can accept
private
static accept_encoding() : string
Return values
string —Accept-Encoding header value
format_get()
Format a URL given GET data
private
static format_get(array<string|int, mixed> $url_parts, array<string|int, mixed>|object $data) : string
Parameters
- $url_parts : array<string|int, mixed>
-
- $data : array<string|int, mixed>|object
-
Return values
string —URL with data