Since: 1.7.3

class SocketTransport extends AbstractTransport implements TransportInterface

HTTP transport class for using sockets directly.

Properties

protected array Since: 1.7.3
$connections

Methods

request(string $method, UriInterface $uri, mixed $data = null, array $headers = [], int $timeout = null, string $userAgent = null)

Send a request to the server and return a Response object with the response.

getResponse(string $content)

Method to get a response object from a server response.

resource
connect(UriInterface $uri, int $timeout = null)

Method to connect to a server and get the resource.

static bool
isSupported()

Method to check if http transport socket available for use

Details

Response request(string $method, UriInterface $uri, mixed $data = null, array $headers = [], int $timeout = null, string $userAgent = null)

Since: 1.7.3

Send a request to the server and return a Response object with the response.

Parameters

string $method

The HTTP method for sending the request.

UriInterface $uri

The URI to the resource to request.

mixed $data

Either an associative array or a string to be sent with the request.

array $headers

An array of request headers to send with the request.

int $timeout

Read timeout in seconds.

string $userAgent

The optional user agent string to send with the request.

Return Value

Response

Exceptions

RuntimeException

protected Response getResponse(string $content)

Since: 1.7.3

Method to get a response object from a server response.

Parameters

string $content

The complete server response, including headers.

Return Value

Response

Exceptions

InvalidResponseCodeException

protected resource connect(UriInterface $uri, int $timeout = null)

Since: 1.7.3

Method to connect to a server and get the resource.

Parameters

UriInterface $uri

The URI to connect with.

int $timeout

Read timeout in seconds.

Return Value

resource

Socket connection resource.

Exceptions

RuntimeException

static bool isSupported()

Since: 3.0.0

Method to check if http transport socket available for use

Return Value

bool

True if available else false