pub struct NetworkRequest<T: ConnectionTransport> {
pub base: BaseParameters,
/* private fields */
}Expand description
Represents a network request that can be intercepted
Fields§
§base: BaseParametersImplementations§
Source§impl<T: ConnectionTransport> NetworkRequest<T>
impl<T: ConnectionTransport> NetworkRequest<T>
pub fn new( params: BeforeRequestSentParameters, session: Arc<Mutex<Session<T>>>, ) -> Self
pub fn from_auth_required( params: AuthRequiredParameters, session: Arc<Mutex<Session<T>>>, ) -> Self
Sourcepub fn request_id(&self) -> &str
pub fn request_id(&self) -> &str
Get the request ID
Sourcepub fn has_post_data(&self) -> bool
pub fn has_post_data(&self) -> bool
Check if the request has POST data (Chrome-specific)
Sourcepub fn post_data(&self) -> Option<&str>
pub fn post_data(&self) -> Option<&str>
Get the POST data as a raw string if available (Chrome-specific)
Sourcepub fn post_data_json(&self) -> Result<Map<String, Value>, PostDataError>
pub fn post_data_json(&self) -> Result<Map<String, Value>, PostDataError>
Parse the POST data as JSON (Chrome-specific) Returns an error if POST data is missing, not valid JSON, or not a JSON object
Sourcepub fn post_data_form(&self) -> Result<HashMap<String, String>, PostDataError>
pub fn post_data_form(&self) -> Result<HashMap<String, String>, PostDataError>
Parse the POST data as URL-encoded form data (Chrome-specific) Returns an error if POST data is missing
Sourcepub async fn is_handled(&self) -> bool
pub async fn is_handled(&self) -> bool
Check if this request has already been handled
Sourcepub async fn get_handled_state(&self) -> Option<NetworkRequestHandledState>
pub async fn get_handled_state(&self) -> Option<NetworkRequestHandledState>
Get the handled state if the request was already handled
Sourcepub async fn continue_(&self) -> Receiver<CommandResponseState>
pub async fn continue_(&self) -> Receiver<CommandResponseState>
Continue the request without modifications
Sourcepub async fn continue_with(
&self,
headers: Option<Vec<Header>>,
cookies: Option<Vec<CookieHeader>>,
url: Option<String>,
method: Option<String>,
body: Option<BytesValue>,
) -> Receiver<CommandResponseState>
pub async fn continue_with( &self, headers: Option<Vec<Header>>, cookies: Option<Vec<CookieHeader>>, url: Option<String>, method: Option<String>, body: Option<BytesValue>, ) -> Receiver<CommandResponseState>
Continue the request with modifications
Sourcepub async fn abort(&self) -> Receiver<CommandResponseState>
pub async fn abort(&self) -> Receiver<CommandResponseState>
Abort/fail the request
Sourcepub async fn respond(
&self,
status_code: Option<u64>,
reason_phrase: Option<String>,
headers: Option<Vec<Header>>,
cookies: Option<Vec<SetCookieHeader>>,
body: Option<BytesValue>,
) -> Receiver<CommandResponseState>
pub async fn respond( &self, status_code: Option<u64>, reason_phrase: Option<String>, headers: Option<Vec<Header>>, cookies: Option<Vec<SetCookieHeader>>, body: Option<BytesValue>, ) -> Receiver<CommandResponseState>
Provide a custom response
Sourcepub async fn continue_with_auth(
&self,
credentials: Option<AuthCredentials>,
) -> Result<(), SessionSendError>
pub async fn continue_with_auth( &self, credentials: Option<AuthCredentials>, ) -> Result<(), SessionSendError>
Continue with HTTP authentication
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for NetworkRequest<T>
impl<T> !RefUnwindSafe for NetworkRequest<T>
impl<T> Send for NetworkRequest<T>where
T: Send,
impl<T> Sync for NetworkRequest<T>where
T: Send,
impl<T> Unpin for NetworkRequest<T>
impl<T> !UnwindSafe for NetworkRequest<T>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more