APIResponse
Playwright\API\APIResponseInterface
Represents an HTTP API response. Status, headers, and body data originate from an API request. Response accessors do not perform additional network requests.
Methods
ok()
boolReports whether the response succeeded. Status codes from 200 through 299 are considered successful. Redirect and client or server errors return false.
function ok(): bool
status()
intReturns the HTTP status code. The value is the code received from the remote server. Use ok() when only the success range matters.
function status(): int
statusText()
stringReturns the HTTP status text. The value comes from the remote server response when available. An empty string represents a missing status text.
function statusText(): string
url()
stringReturns the final response URL. Redirects can make this differ from the request URL. An empty string represents a missing URL in the protocol response.
function url(): string
headers()
arrayReturns one value per response header. Repeated headers retain their first value in this representation. Header names preserve the casing supplied by the server.
function headers(): array
headersArray()
arrayReturns all values for every response header. Repeated headers remain separate values in the returned arrays. Header names preserve the casing supplied by the server.
function headersArray(): array
headerValue()
?stringReturns the first value for a response header. Header name matching is case-insensitive. Returns null when the response does not contain the requested header.
function headerValue(string $name): ?string
headerValues()
arrayReturns all values for a response header. Header name matching is case-insensitive. The returned array is empty when the response does not contain the header.
function headerValues(string $name): array
body()
stringReturns the response body as text. This is an alias for text() provided for API parity. No content decoding is applied beyond the Playwright protocol response.
function body(): string
json()
arrayDecodes the response body as JSON. The top-level JSON value must be an object or array. Invalid JSON raises a Playwright exception.
function json(): array
text()
stringReturns the response body as text. The returned string is the body received through the Playwright protocol. An empty string represents a missing body.
function text(): string
dispose()
voidReleases response resources. Call this when a response implementation holds disposable resources. The bundled implementation currently retains only in-memory response data.
function dispose(): void