Struct ureq::RequestUrl

source ·
pub struct RequestUrl { /* private fields */ }
Expand description

Parsed result of a request url with handy inspection methods.

Implementations§

source§

impl RequestUrl

source

pub fn as_url(&self) -> &Url

Handle the request url as a standard url::Url.

source

pub fn scheme(&self) -> &str

Get the scheme of the request url, i.e. “https” or “http”.

source

pub fn host(&self) -> &str

Host of the request url.

source

pub fn port(&self) -> Option<u16>

Port of the request url, if available. Ports are only available if they are present in the original url. Specifically the scheme default ports, 443 for https and and 80 for http are None unless explicitly set in the url, i.e. https://my-host.com:443/some/path.

source

pub fn path(&self) -> &str

Path of the request url.

source

pub fn query_pairs(&self) -> Vec<(&str, &str)>

Returns all query parameters as a vector of key-value pairs.

let req = ureq::get("http://httpbin.org/get")
    .query("foo", "42")
    .query("foo", "43");

assert_eq!(req.request_url()?.query_pairs(), vec![
    ("foo", "42"),
    ("foo", "43")
]);

Trait Implementations§

source§

impl Clone for RequestUrl

source§

fn clone(&self) -> RequestUrl

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RequestUrl

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.