pub struct Route {
inner: Weak<Route>,
}Expand description
Whenever a network route is set up with [method: Page.route] or [method: BrowserContext.route], the Route object
allows to handle the route.
Fields§
§inner: Weak<Route>Implementations§
Source§impl Route
impl Route
fn new(inner: Weak<Impl>) -> Self
Sourcepub async fn abort(&self, err_code: Option<&str>) -> Result<(), Arc<Error>>
pub async fn abort(&self, err_code: Option<&str>) -> Result<(), Arc<Error>>
Aborts the route’s request.
Optional error code. Defaults to failed, could be one of the following:
'aborted'- An operation was aborted (due to user action)'accessdenied'- Permission to access a resource, other than the network, was denied'addressunreachable'- The IP address is unreachable. This usually means that there is no route to the specified host or network.'blockedbyclient'- The client chose to block the request.'blockedbyresponse'- The request failed because the response was delivered along with requirements which are not met (‘X-Frame-Options’ and ‘Content-Security-Policy’ ancestor checks, for instance).'connectionaborted'- A connection timed out as a result of not receiving an ACK for data sent.'connectionclosed'- A connection was closed (corresponding to a TCP FIN).'connectionfailed'- A connection attempt failed.'connectionrefused'- A connection attempt was refused.'connectionreset'- A connection was reset (corresponding to a TCP RST).'internetdisconnected'- The Internet connection has been lost.'namenotresolved'- The host name could not be resolved.'timedout'- An operation timed out.'failed'- A generic failure occurred.
Sourcepub async fn fulfill_builder<'a>(
&self,
body: &'a str,
is_base64: bool,
) -> FulfillBuilder<'a, '_>
pub async fn fulfill_builder<'a>( &self, body: &'a str, is_base64: bool, ) -> FulfillBuilder<'a, '_>
Fulfills route’s request with given response.
An example of fulfilling all requests with 404 responses:
await page.route('**/*', route => {
route.fulfill({
status: 404,
contentType: 'text/plain',
body: 'Not Found!'
});
});Sourcepub async fn continue_builder(&self) -> ContinueBuilder<'_, '_, '_>
pub async fn continue_builder(&self) -> ContinueBuilder<'_, '_, '_>
Continues route’s request with optional overrides.
await page.route('**/*', (route, request) => {
// Override headers
const headers = {
...request.headers(),
foo: 'bar', // set "foo" header
origin: undefined, // remove "origin" header
};
route.continue({headers});
});Trait Implementations§
Auto Trait Implementations§
impl Freeze for Route
impl RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnwindSafe for Route
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more