Class Request
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The Request interface of the Fetch API represents a resource request.
[Value("Request")]
public class Request
- Inheritance
-
Request
- Inherited Members
Remarks
You can create a new Request object using the Request(Union42, RequestInit) constructor, but you are more likely to encounter a Request object being returned as the result of another API operation, such as a service worker Request.
Constructors
Request()
public Request()
Request(Union42, RequestInit)
The Request() constructor creates a new
Request object.
public Request(Union42 input, RequestInit init = null)
Parameters
inputUnion42initRequestInit
Remarks
Properties
Cache
The cache read-only property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache.
[Value("cache")]
public RequestCache Cache { get; }
Property Value
- RequestCache
A
RequestCachevalue. The available values are:
Remarks
Credentials
The credentials read-only property of the Request interface reflects the value given to the Request(Union42, RequestInit) constructor in the credentials option. It determines whether or not the browser sends credentials with the request, as well as whether any Set-Cookie response headers are respected.
[Value("credentials")]
public RequestCredentials Credentials { get; }
Property Value
- RequestCredentials
A string with one of the following values:
Remarks
Credentials are cookies, TLS client certificates, or authentication headers containing a username and password.
See Including credentials for more details.
Destination
The destination read-only property of the Request interface returns a string describing the type of content being requested.
[Value("destination")]
public RequestDestination Destination { get; }
Property Value
- RequestDestination
A string which indicates the type of content the request is asking for. This type is much broader than the usual document type values (such as
"document"or"manifest"), and may include contextual cues such as"image"or"worker"or"audioworklet".Possible values are:
Remarks
The string must be one of the audio, audioworklet, document, embed, fencedframe, font, frame, iframe, image, json, manifest, object, paintworklet, report, script, sharedworker, speculationrules, style, track, video, worker or xslt strings, or the empty string, which is the default value.
The destination is used by the user agent to, for example, help determine which set of rules to follow for CORS purposes, or how to navigate any complicated code paths that affect how specific types of request get handled.
These destinations vary substantially in how they operate. Some are data receptacles, where the received data is stored for processing later. Others are script-based, in which case the received data is delivered to a script by calling it and passing the data along.
Script-based destinations include {{HTMLElement("script")}} elements, as well as any of the Worklet-based destinations (including subclasses like AudioWorklet), and the Worker-based destinations, including ServiceWorker and SharedWorker.
Duplex
NOTE
Experimentalduplex read-only property of the Request interface returns the duplex mode of the request, which determines whether the browser must send the entire request before processing the response.
[Value("duplex")]
public RequestDuplex Duplex { get; }
Property Value
- RequestDuplex
A string with the following possible value:
Remarks
-Fetch API
-Request(Union42, RequestInit) constructor
-RequestInit.duplex in request options
-Consuming a fetch as a stream
Headers
The headers read-only property of the
Request interface contains the Headers object associated
with the request.
[Value("headers")]
public Headers Headers { get; }
Property Value
Remarks
Integrity
The integrity read-only property of the Request interface contains the subresource integrity value of the request.
[Value("integrity")]
public string Integrity { get; }
Property Value
- string
The value that was passed as the
options.integrityargument when constructing theRequest.If an integrity has not been specified, the property returns''.
Remarks
IsHistoryNavigation
The isHistoryNavigation read-only property of the Request interface is a boolean indicating whether the request is a history navigation.
[Value("isHistoryNavigation")]
public bool IsHistoryNavigation { get; }
Property Value
- bool
A boolean value.
Remarks
A history navigation is a navigation within the browser's history, made by calling Go(long), Back(), Forward(), TraverseTo(string, NavigationOptions), Back(NavigationOptions), Forward(NavigationOptions), or directly by clicking the browser's back or forward navigation button.
-{{domxref("History API", "", "", 1)}}
-{{domxref("Navigation API", "", "", 1)}}
-{{domxref("Service Worker API", "", "", 1)}}
IsReloadNavigation
[Value("isReloadNavigation")]
public bool IsReloadNavigation { get; }
Property Value
Keepalive
The keepalive read-only property of the Request interface contains the request's keepalive setting (true or false), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.
[Value("keepalive")]
public bool Keepalive { get; }
Property Value
- bool
A boolean value indicating the
keepalivestatus of the request.
Remarks
This enables a 'Window.Fetch' request to, for example, send analytics at the end of a session even if the user navigates away from or closes the page.
This has some advantages over using SendBeacon(string, Union41?) for the same purpose, including allowing you to use HTTP methods other than POST, customize request properties, and access the server response via the fetch Promise fulfillment.
It is also available in service workers.
Method
The method read-only property of the
Request interface contains the request's method (GET,POST, etc.)
[Value("method")]
public string Method { get; }
Property Value
Remarks
Mode
The mode read-only property of the Request
interface contains the mode of the request (e.g., cors,no-cors, same-origin, or navigate.) This is used
to determine if cross-origin requests lead to valid responses, and which properties of the response are readable.
[Value("mode")]
public RequestMode Mode { get; }
Property Value
- RequestMode
One of the following values:
Remarks
To construct a request with a specific mode, pass the desired value as the {{domxref("RequestInit", "", "mode")}} option to the Request(Union42, RequestInit) constructor.
Note that setting particular modes, especially no-cors, places restrictions on the request methods and headers that may be used, and prevents JavaScript from accessing the response headers or body. See the documentation for {{domxref("RequestInit", "", "mode")}} for more details.
Redirect
The redirect read-only property of the Request interface contains the mode for how redirects are handled.
[Value("redirect")]
public RequestRedirect Redirect { get; }
Property Value
- RequestRedirect
A
RequestRedirectenum value, which can be one the following strings:If not specified when the request is created, it takes the default value offollow.
Remarks
Referrer
The referrer read-only property of the
Request interface is set by the user agent to be the referrer of the
Request. (e.g., client, no-referrer, or a URL.)
[Value("referrer")]
public string Referrer { get; }
Property Value
- string
A string representing the request's referrer.
Remarks
NOTE
If
referrer's value isno-referrer,
it returns an empty string.
ReferrerPolicy
The referrerPolicy read-only property of the
Request interface returns the referrer policy, which governs what
referrer information, sent in the Referer header, should be included
with the request.
[Value("referrerPolicy")]
public ReferrerPolicy ReferrerPolicy { get; }
Property Value
- ReferrerPolicy
A string representing the request's
referrerPolicy. For
more information and possible values, see the Referrer-Policy HTTP
header page.
Remarks
Signal
The read-only signal property of the Request interface returns the AbortSignal associated with the request.
[Value("signal")]
public AbortSignal Signal { get; }
Property Value
- AbortSignal
An AbortSignal object.
Remarks
TargetAddressSpace
[Value("targetAddressSpace")]
public IPAddressSpace TargetAddressSpace { get; }
Property Value
Url
The url read-only property of the Request
interface contains the URL of the request.
[Value("url")]
public string Url { get; }
Property Value
- string
A string indicating the URL of the request.
Remarks
Methods
Clone()
The clone() method of the Request interface creates a copy of the current Request object.
[Value("clone")]
public Request Clone()
Returns
Remarks
Like the underlying Tee() api,
the Request.Body of a cloned Request
will signal backpressure at the rate of the faster consumer of the two bodies,
and unread data is enqueued internally on the slower consumed body
without any limit or backpressure.
Beware when you construct a Request from a stream and then clone it.
clone() throws a TypeError if the request body has already been used. In fact, the main reason clone() exists is to allow multiple uses of body objects (when they are one-use only.)
If you intend to modify the request, you may prefer the Request constructor.