APIResponse class represents responses returned by Playwright.APIRequestContext.get/3 and similar methods.
Since Playwright 1.16.
The examples alias the modules they use (alias Playwright.{Locator, Page}).
Summary
Functions
Returns the buffer with response body.
Like body/1, but returns the value and raises on error.
Disposes the body of this response. If not called then the body will stay in memory until the context closes.
Like dispose/1, but returns the value and raises on error.
An object with all the response HTTP headers associated with this response.
An array with all the response HTTP headers associated with this response. Header names are not lower-cased.
Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.
Returns the JSON representation of response body.
Like json/1, but returns the value and raises on error.
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
Returns SSL and other security information. Returns nil for non-HTTPS responses. For redirected requests, returns the information for the last request in the redirect chain.
Like security_details/1, but returns the value and raises on error.
Returns the IP address and port of the server. Returns nil if the server address is not available. For redirected requests, returns the information for the last request in the redirect chain.
Like server_addr/1, but returns the value and raises on error.
Contains the status code of the response (e.g., 200 for a success).
Contains the status text of the response (e.g. usually an "OK" for a success).
Returns the text representation of response body.
Like text/1, but returns the value and raises on error.
Returns resource timing information for given response. For redirected requests, returns the information for the last request in the redirect chain. When the response is served from the HAR file, timing information is not available and all the values are -1. Find more information at Resource Timing API.
Contains the URL of the response.
Types
Functions
@spec body(t()) :: {:ok, binary()} | {:error, Playwright.error()}
Returns the buffer with response body.
Since Playwright 1.16.
Like body/1, but returns the value and raises on error.
@spec dispose(t()) :: :ok | {:error, Playwright.error()}
Disposes the body of this response. If not called then the body will stay in memory until the context closes.
Since Playwright 1.16.
@spec dispose!(t()) :: :ok
Like dispose/1, but returns the value and raises on error.
An object with all the response HTTP headers associated with this response.
Since Playwright 1.16.
An array with all the response HTTP headers associated with this response. Header names are not lower-cased.
Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.
Since Playwright 1.16.
@spec json(t()) :: {:ok, term()} | {:error, Playwright.error()}
Returns the JSON representation of response body.
This method will fail if the response body is not parsable via JSON.parse.
Since Playwright 1.16.
Like json/1, but returns the value and raises on error.
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
Since Playwright 1.16.
@spec security_details(t()) :: {:ok, nil | %{ optional(:issuer) => String.t(), optional(:protocol) => String.t(), optional(:subjectName) => String.t(), optional(:validFrom) => number(), optional(:validTo) => number() }} | {:error, Playwright.error()}
Returns SSL and other security information. Returns nil for non-HTTPS responses. For redirected requests, returns the information for the last request in the redirect chain.
Since Playwright 1.61.
@spec security_details!(t()) :: nil | %{ optional(:issuer) => String.t(), optional(:protocol) => String.t(), optional(:subjectName) => String.t(), optional(:validFrom) => number(), optional(:validTo) => number() }
Like security_details/1, but returns the value and raises on error.
@spec server_addr(t()) :: {:ok, nil | %{ipAddress: String.t(), port: integer()}} | {:error, Playwright.error()}
Returns the IP address and port of the server. Returns nil if the server address is not available. For redirected requests, returns the information for the last request in the redirect chain.
Since Playwright 1.61.
Like server_addr/1, but returns the value and raises on error.
Contains the status code of the response (e.g., 200 for a success).
Since Playwright 1.16.
Contains the status text of the response (e.g. usually an "OK" for a success).
Since Playwright 1.16.
@spec text(t()) :: {:ok, String.t()} | {:error, Playwright.error()}
Returns the text representation of response body.
Since Playwright 1.16.
Like text/1, but returns the value and raises on error.
@spec timing(t()) :: %{ startTime: number(), domainLookupStart: number(), domainLookupEnd: number(), connectStart: number(), secureConnectionStart: number(), connectEnd: number(), requestStart: number(), responseStart: number(), responseEnd: number() }
Returns resource timing information for given response. For redirected requests, returns the information for the last request in the redirect chain. When the response is served from the HAR file, timing information is not available and all the values are -1. Find more information at Resource Timing API.
Since Playwright 1.62.
Contains the URL of the response.
Since Playwright 1.16.