pub struct APIRequestContext { /* private fields */ }Expand description
APIRequestContext provides methods for making HTTP requests.
This is the Playwright protocol object that performs actual HTTP operations.
It is created automatically for each BrowserContext and can be accessed
via BrowserContext::request().
Used internally by Route::fetch() to perform the actual network request.
See: https://playwright.dev/docs/api/class-apirequestcontext
Implementations§
Source§impl APIRequestContext
impl APIRequestContext
pub fn new( parent: ParentOrConnection, type_name: String, guid: Arc<str>, initializer: Value, ) -> Result<Self>
Sourcepub async fn get(
&self,
url: &str,
options: Option<FetchOptions>,
) -> Result<APIResponse>
pub async fn get( &self, url: &str, options: Option<FetchOptions>, ) -> Result<APIResponse>
Sends a GET request.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
Sourcepub async fn post(
&self,
url: &str,
options: Option<FetchOptions>,
) -> Result<APIResponse>
pub async fn post( &self, url: &str, options: Option<FetchOptions>, ) -> Result<APIResponse>
Sends a POST request.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-post
Sourcepub async fn put(
&self,
url: &str,
options: Option<FetchOptions>,
) -> Result<APIResponse>
pub async fn put( &self, url: &str, options: Option<FetchOptions>, ) -> Result<APIResponse>
Sends a PUT request.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-put
Sourcepub async fn delete(
&self,
url: &str,
options: Option<FetchOptions>,
) -> Result<APIResponse>
pub async fn delete( &self, url: &str, options: Option<FetchOptions>, ) -> Result<APIResponse>
Sends a DELETE request.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-delete
Sourcepub async fn patch(
&self,
url: &str,
options: Option<FetchOptions>,
) -> Result<APIResponse>
pub async fn patch( &self, url: &str, options: Option<FetchOptions>, ) -> Result<APIResponse>
Sends a PATCH request.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-patch
Sourcepub async fn head(
&self,
url: &str,
options: Option<FetchOptions>,
) -> Result<APIResponse>
pub async fn head( &self, url: &str, options: Option<FetchOptions>, ) -> Result<APIResponse>
Sends a HEAD request.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-head
Sourcepub async fn fetch(
&self,
url: &str,
options: Option<FetchOptions>,
) -> Result<APIResponse>
pub async fn fetch( &self, url: &str, options: Option<FetchOptions>, ) -> Result<APIResponse>
Sends a fetch request with the given options, returning an APIResponse.
This is the public-facing fetch method that returns a lazy APIResponse.
The response body is not fetched until body(), text(), or json() is called.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-fetch
Sourcepub async fn dispose(&self) -> Result<()>
pub async fn dispose(&self) -> Result<()>
Disposes this APIRequestContext, freeing server resources.
After calling dispose(), the context cannot be used for further requests.
See: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-dispose
Trait Implementations§
Source§impl Clone for APIRequestContext
impl Clone for APIRequestContext
Source§fn clone(&self) -> APIRequestContext
fn clone(&self) -> APIRequestContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more