pub struct Request { /* private fields */ }
Expand description
A wrapper round web_sys::Request
: an http request to be used with the fetch
API.
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(url: &str) -> Request
pub fn new(url: &str) -> Request
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) -> Request
pub fn cache(self, cache: RequestCache) -> Request
A string indicating how the request will interact with the browser’s HTTP cache.
Sourcepub fn credentials(self, credentials: RequestCredentials) -> Request
pub fn credentials(self, credentials: RequestCredentials) -> Request
Controls what browsers do with credentials (cookies, HTTP authentication entries, and TLS client certificates).
Sourcepub fn integrity(self, integrity: &str) -> Request
pub fn integrity(self, integrity: &str) -> Request
The subresource integrity value of the request (e.g.,
sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=
).
Sourcepub fn method(self, method: Method) -> Request
pub fn method(self, method: Method) -> Request
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) -> Request
pub fn mode(self, mode: RequestMode) -> Request
The mode you want to use for the request.
Sourcepub fn observe(self, observe: &ObserverCallback) -> Request
pub fn observe(self, observe: &ObserverCallback) -> Request
Sets the observer callback.
Sourcepub fn redirect(self, redirect: RequestRedirect) -> Request
pub fn redirect(self, redirect: RequestRedirect) -> Request
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) -> Request
pub fn referrer(self, referrer: &str) -> Request
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) -> Request
pub fn referrer_policy(self, referrer_policy: ReferrerPolicy) -> Request
Specifies the referrer policy to use for the request.
Sourcepub fn abort_signal(self, signal: Option<&AbortSignal>) -> Request
pub fn abort_signal(self, signal: Option<&AbortSignal>) -> Request
Sets the request abort signal.