pub struct APIResponse { /* private fields */ }Expand description
A lazy HTTP response returned by APIRequestContext methods.
Unlike crate::protocol::route::FetchResponse (which eagerly fetches the body),
APIResponse holds a fetch_uid and fetches the body on demand.
Implementations§
Source§impl APIResponse
impl APIResponse
Sourcepub fn status_text(&self) -> &str
pub fn status_text(&self) -> &str
Returns the HTTP status text (e.g., “OK”, “Not Found”).
Sourcepub fn headers(&self) -> &HashMap<String, String>
pub fn headers(&self) -> &HashMap<String, String>
Returns the response headers as a HashMap<String, String>.
Sourcepub async fn body(&self) -> Result<Vec<u8>>
pub async fn body(&self) -> Result<Vec<u8>>
Fetches and returns the response body as bytes.
See: https://playwright.dev/docs/api/class-apiresponse#api-response-body
Sourcepub async fn text(&self) -> Result<String>
pub async fn text(&self) -> Result<String>
Fetches and returns the response body as a UTF-8 string.
See: https://playwright.dev/docs/api/class-apiresponse#api-response-text
Sourcepub async fn json<T: DeserializeOwned>(&self) -> Result<T>
pub async fn json<T: DeserializeOwned>(&self) -> Result<T>
Fetches the response body and deserializes it as JSON.
See: https://playwright.dev/docs/api/class-apiresponse#api-response-json
Sourcepub async fn dispose(&self) -> Result<()>
pub async fn dispose(&self) -> Result<()>
Disposes this response, freeing server-side resources for the response body.
See: https://playwright.dev/docs/api/class-apiresponse#api-response-dispose
Trait Implementations§
Source§impl Clone for APIResponse
impl Clone for APIResponse
Source§fn clone(&self) -> APIResponse
fn clone(&self) -> APIResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more