pub struct Response { /* private fields */ }Expand description
Response from navigation operations.
Returned from page.goto(), page.reload(), page.go_back(), and similar
navigation methods. Provides access to the HTTP response status, headers, and body.
Implementations§
Source§impl Response
impl Response
Sourcepub fn url(&self) -> &str
pub fn url(&self) -> &str
Returns the URL of the response.
See: https://playwright.dev/docs/api/class-response#response-url
Sourcepub fn status(&self) -> u16
pub fn status(&self) -> u16
Returns the HTTP status code.
See: https://playwright.dev/docs/api/class-response#response-status
Sourcepub fn status_text(&self) -> &str
pub fn status_text(&self) -> &str
Returns the HTTP status text.
See: https://playwright.dev/docs/api/class-response#response-status-text
Sourcepub fn ok(&self) -> bool
pub fn ok(&self) -> bool
Returns whether the response was successful (status 200-299).
See: https://playwright.dev/docs/api/class-response#response-ok
Sourcepub fn headers(&self) -> &HashMap<String, String>
pub fn headers(&self) -> &HashMap<String, String>
Returns the response headers as a HashMap.
Note: these are the headers from the protocol initializer. For the full
raw headers (including duplicates), use headers_array() or all_headers().
See: https://playwright.dev/docs/api/class-response#response-headers
Sourcepub fn request(&self) -> Option<Request>
pub fn request(&self) -> Option<Request>
Returns the Request that triggered this response.
Navigates the protocol object hierarchy: ResponseObject → parent (Request).
See: https://playwright.dev/docs/api/class-response#response-request
Sourcepub fn frame(&self) -> Option<Frame>
pub fn frame(&self) -> Option<Frame>
Returns the Frame that initiated the request for this response.
Navigates the protocol object hierarchy: ResponseObject → Request → Frame.
See: https://playwright.dev/docs/api/class-response#response-frame
Sourcepub async fn security_details(&self) -> Result<Option<SecurityDetails>>
pub async fn security_details(&self) -> Result<Option<SecurityDetails>>
Returns TLS/SSL security details for HTTPS connections, or None for HTTP.
See: https://playwright.dev/docs/api/class-response#response-security-details
Sourcepub async fn server_addr(&self) -> Result<Option<RemoteAddr>>
pub async fn server_addr(&self) -> Result<Option<RemoteAddr>>
Returns the server’s IP address and port, or None.
See: https://playwright.dev/docs/api/class-response#response-server-addr
Sourcepub async fn finished(&self) -> Result<()>
pub async fn finished(&self) -> Result<()>
Waits for this response to finish loading.
For responses obtained from navigation methods (goto, reload), the response
is already finished when returned. For responses from on_response handlers,
the body may still be loading.
See: https://playwright.dev/docs/api/class-response#response-finished
Sourcepub async fn body(&self) -> Result<Vec<u8>>
pub async fn body(&self) -> Result<Vec<u8>>
Returns the response body as raw bytes.
Makes an RPC call to the Playwright server to fetch the response body.
§Errors
Returns an error if:
- No backing protocol object is available (edge case)
- The RPC call to the server fails
- The base64 response cannot be decoded
See: https://playwright.dev/docs/api/class-response#response-body
Sourcepub async fn text(&self) -> Result<String>
pub async fn text(&self) -> Result<String>
Returns the response body as a UTF-8 string.
Calls body() then converts bytes to a UTF-8 string.
§Errors
Returns an error if:
body()fails- The body is not valid UTF-8
See: https://playwright.dev/docs/api/class-response#response-text
Sourcepub async fn json<T: DeserializeOwned>(&self) -> Result<T>
pub async fn json<T: DeserializeOwned>(&self) -> Result<T>
Parses the response body as JSON and deserializes it into type T.
Calls text() then uses serde_json to deserialize the body.
§Errors
Returns an error if:
text()fails- The body is not valid JSON or doesn’t match the expected type
See: https://playwright.dev/docs/api/class-response#response-json
Sourcepub async fn headers_array(&self) -> Result<Vec<HeaderEntry>>
pub async fn headers_array(&self) -> Result<Vec<HeaderEntry>>
Returns all response headers as name-value pairs, preserving duplicates.
Makes an RPC call for "rawHeaders" which returns the complete header list.
§Errors
Returns an error if:
- No backing protocol object is available (edge case)
- The RPC call to the server fails
See: https://playwright.dev/docs/api/class-response#response-headers-array
Sourcepub async fn all_headers(&self) -> Result<HashMap<String, String>>
pub async fn all_headers(&self) -> Result<HashMap<String, String>>
Returns all response headers merged into a HashMap with lowercase keys.
When multiple headers have the same name, their values are joined with , .
This matches the behavior of response.allHeaders() in other Playwright bindings.
§Errors
Returns an error if:
- No backing protocol object is available (edge case)
- The RPC call to the server fails
See: https://playwright.dev/docs/api/class-response#response-all-headers
Sourcepub async fn header_value(&self, name: &str) -> Result<Option<String>>
pub async fn header_value(&self, name: &str) -> Result<Option<String>>
Returns the value for a single response header, or None if not present.
The lookup is case-insensitive.
§Errors
Returns an error if:
- No backing protocol object is available (edge case)
- The RPC call to the server fails
See: https://playwright.dev/docs/api/class-response#response-header-value
Returns the value for a single response header, or None if not present.
The lookup is case-insensitive. When multiple headers share the same name,
their values are joined with , (matching Playwright’s behavior).
Uses the raw headers from the server for accurate results.
§Errors
Returns an error if the underlying headers_array() RPC call fails.
See: https://playwright.dev/docs/api/class-response#response-header-value