Amp\Artax\Response interface Response

An HTTP response.

This interface allows mocking responses and allows custom implementations.

DefaultClient uses an anonymous class to implement this interface.

Summary

Properties

Methods

Methods

getProtocolVersion — public function getProtocolVersion(): string

Retrieve the requests's HTTP protocol version.

getStatus — public function getStatus(): int

Retrieve the response's three-digit HTTP status code.

getReason — public function getReason(): string

Retrieve the response's (possibly empty) reason phrase.

getRequest — public function getRequest(): Amp\Artax\Request

Retrieve the Request instance that resulted in this Response instance.

getOriginalRequest — public function getOriginalRequest(): Amp\Artax\Request

Retrieve the original Request instance associated with this Response instance.

A given Response may be the result of one or more redirects. This method is a shortcut to access information from the original Request that led to this response.

getPreviousResponse — public function getPreviousResponse(): Amp\Artax\Response|null

If this Response is the result of a redirect traverse up the redirect history.

hasHeader — public function hasHeader(string $field): bool

Does the message contain the specified header field (case-insensitive)?

Type Parameter Description Default Value
string $field Header name. none
getHeader — public function getHeader(string $field): string|null

Retrieve the first occurrence of the specified header in the message.

If multiple headers exist for the specified field only the value of the first header is returned. Applications may use getHeaderArray() to retrieve a list of all header values received for a given field.

A null return indicates the requested header field was not present.

Type Parameter Description Default Value
string $field Header name. none
getHeaderArray — public function getHeaderArray(string $field): array

Retrieve all occurrences of the specified header in the message.

Applications may use getHeader() to access only the first occurrence.

Type Parameter Description Default Value
string $field Header name. none
getHeaders — public function getHeaders(): array

Retrieve an associative array of headers matching field names to an array of field values.

Format

[
    "header-1" => [
        "value-1",
        "value-2",
    ],
    "header-2" => [
        "value-1",
    ],
]
getBody — public function getBody(): Amp\Artax\Message

Retrieve the response body.

Note: If you stream a Message, you can't consume the payload twice.

getMetaInfo — public function getMetaInfo(): Amp\Artax\MetaInfo
No documentation.