NetworkRequest

Struct NetworkRequest 

Source
pub struct NetworkRequest<T: ConnectionTransport> {
    pub base: BaseParameters,
    /* private fields */
}
Expand description

Represents a network request that can be intercepted

Fields§

§base: BaseParameters

Implementations§

Source§

impl<T: ConnectionTransport> NetworkRequest<T>

Source

pub fn new( params: BeforeRequestSentParameters, session: Arc<Mutex<Session<T>>>, ) -> Self

Source

pub fn from_auth_required( params: AuthRequiredParameters, session: Arc<Mutex<Session<T>>>, ) -> Self

Source

pub fn request_id(&self) -> &str

Get the request ID

Source

pub fn url(&self) -> &str

Get the request URL

Source

pub fn headers(&self) -> &Vec<Header>

Get the request headers

Source

pub fn method(&self) -> &str

Get the request method

Source

pub fn has_post_data(&self) -> bool

Check if the request has POST data (Chrome-specific)

Source

pub fn post_data(&self) -> Option<&str>

Get the POST data as a raw string if available (Chrome-specific)

Source

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

Source

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

Source

pub async fn is_handled(&self) -> bool

Check if this request has already been handled

Source

pub async fn get_handled_state(&self) -> Option<NetworkRequestHandledState>

Get the handled state if the request was already handled

Source

pub async fn continue_(&self) -> Receiver<CommandResponseState>

Continue the request without modifications

Source

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

Source

pub async fn abort(&self) -> Receiver<CommandResponseState>

Abort/fail the request

Source

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

Source

pub async fn continue_with_auth( &self, credentials: Option<AuthCredentials>, ) -> Result<(), SessionSendError>

Continue with HTTP authentication

Trait Implementations§

Source§

impl<T: ConnectionTransport> Debug for NetworkRequest<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more