pub struct Request { /* private fields */ }
http
only.Expand description
A wrapper round web_sys::Request
: an http request to be used with the fetch
API.
Implementations
sourceimpl Request
impl Request
sourcepub fn new(url: &str) -> Self
pub fn new(url: &str) -> Self
Creates a new request that will be sent to url
.
Uses GET
by default. url
can be a String
, a &str
, or a Cow<'a, str>
.
sourcepub fn cache(self, cache: RequestCache) -> Self
pub fn cache(self, cache: RequestCache) -> Self
A string indicating how the request will interact with the browser’s HTTP cache.
sourcepub fn credentials(self, credentials: RequestCredentials) -> Self
pub fn credentials(self, credentials: RequestCredentials) -> Self
Controls what browsers do with credentials (cookies, HTTP authentication entries, and TLS client certificates).
sourcepub fn integrity(self, integrity: &str) -> Self
pub fn integrity(self, integrity: &str) -> Self
The subresource integrity value of the request (e.g.,
sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=
).
sourcepub fn method(self, method: Method) -> Self
pub fn method(self, method: Method) -> Self
The request method, e.g., GET, POST.
Note that the Origin header is not set on Fetch requests with a method of HEAD or GET.
sourcepub fn mode(self, mode: RequestMode) -> Self
pub fn mode(self, mode: RequestMode) -> Self
The mode you want to use for the request.
sourcepub fn observe(self, observe: &ObserverCallback) -> Self
pub fn observe(self, observe: &ObserverCallback) -> Self
Sets the observer callback.
sourcepub fn redirect(self, redirect: RequestRedirect) -> Self
pub fn redirect(self, redirect: RequestRedirect) -> Self
How to handle a redirect response:
- follow: Automatically follow redirects. Unless otherwise stated the redirect mode is set to follow
- error: Abort with an error if a redirect occurs.
- manual: Caller intends to process the response in another context. See WHATWG fetch standard for more information.
sourcepub fn referrer(self, referrer: &str) -> Self
pub fn referrer(self, referrer: &str) -> Self
The referrer of the request.
This can be a same-origin URL, about:client
, or an empty string.
sourcepub fn referrer_policy(self, referrer_policy: ReferrerPolicy) -> Self
pub fn referrer_policy(self, referrer_policy: ReferrerPolicy) -> Self
Specifies the referrer policy to use for the request.
sourcepub fn abort_signal(self, signal: Option<&AbortSignal>) -> Self
pub fn abort_signal(self, signal: Option<&AbortSignal>) -> Self
Sets the request abort signal.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Request
impl !Send for Request
impl !Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more