pub struct HttpRequest {
pub method: String,
pub url: String,
pub headers: Vec<(String, String)>,
pub body: HttpBody,
pub follow_redirects: bool,
pub cache: HttpCache,
}Expand description
An HTTP request for the platform’s network stack (made by JS fetch
and by Rust components’ crate::element::fetch).
Fields§
§method: StringUpper-case method (GET, POST, …).
url: StringAbsolute URL.
headers: Vec<(String, String)>Header names and values, in order; names may repeat.
body: HttpBodyRequest body.
follow_redirects: boolFollow redirects (redirect: "follow", the default).
cache: HttpCacheHow the request uses the platform’s HTTP cache (cache of
fetch).
Implementations§
Source§impl HttpRequest
impl HttpRequest
Sourcepub fn new(method: impl Into<String>, url: impl Into<String>) -> HttpRequest
pub fn new(method: impl Into<String>, url: impl Into<String>) -> HttpRequest
A request of method (GET, POST, …; upper-cased) to url,
with no headers or body, following redirects.
Sourcepub fn get(url: impl Into<String>) -> HttpRequest
pub fn get(url: impl Into<String>) -> HttpRequest
A GET of url.
Sourcepub fn post(url: impl Into<String>, body: impl Into<Vec<u8>>) -> HttpRequest
pub fn post(url: impl Into<String>, body: impl Into<Vec<u8>>) -> HttpRequest
A POST of body to url.
Sourcepub fn header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> HttpRequest
pub fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> HttpRequest
Adds the header name: value.
Sourcepub fn cache(self, cache: HttpCache) -> HttpRequest
pub fn cache(self, cache: HttpCache) -> HttpRequest
Uses the HTTP cache as cache says.
Trait Implementations§
Source§impl Clone for HttpRequest
impl Clone for HttpRequest
Source§fn clone(&self) -> HttpRequest
fn clone(&self) -> HttpRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpRequest
impl Debug for HttpRequest
impl Eq for HttpRequest
Source§impl From<&str> for HttpRequest
impl From<&str> for HttpRequest
Source§fn from(url: &str) -> HttpRequest
fn from(url: &str) -> HttpRequest
Converts to this type from the input type.
Source§impl From<String> for HttpRequest
impl From<String> for HttpRequest
Source§fn from(url: String) -> HttpRequest
fn from(url: String) -> HttpRequest
Converts to this type from the input type.
Source§impl PartialEq for HttpRequest
impl PartialEq for HttpRequest
impl StructuralPartialEq for HttpRequest
Auto Trait Implementations§
impl Forget for HttpRequest
impl Freeze for HttpRequest
impl Move for HttpRequest
impl RefUnwindSafe for HttpRequest
impl Send for HttpRequest
impl Sync for HttpRequest
impl Unpin for HttpRequest
impl UnsafeUnpin for HttpRequest
impl UnwindSafe for HttpRequest
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.