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
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
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
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]
.
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