Class WebRequest
Implements
- IWebRequest
Constructors
constructor
-
Returns WebRequest
Properties
StaticCustom Request Headers
Custom HTTP Request Headers to be sent with XMLHttpRequests i.e. when loading files, where the server/service expects an Authorization header
StaticCustom Request Modifiers
(request: XMLHttpRequest, url: string) => string | void
)[] = ...
Add callback functions in this array to update all the requests before they get sent to the network
StaticSkip Request Modification For Babylon CDN
If set to true, requests to Babylon.js CDN requests will not be modified
Accessors
onprogress
-
get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null
Gets or sets a function to be called when loading progress changes
Returns ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null
-
set onprogress(
value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null,
): voidParameters
- value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null
Returns void
ready State
-
get readyState(): number
Returns client's state
Returns number
request URL
-
get requestURL(): string
Returns the requested URL once open has been called
Returns string
response
-
get response(): any
Returns client's response
Returns any
response Text
-
get responseText(): string
Returns client's response as text
Returns string
response Type
-
get responseType(): XMLHttpRequestResponseType
Gets or sets the expected response type
Returns XMLHttpRequestResponseType
-
set responseType(value: XMLHttpRequestResponseType): void
Parameters
- value: XMLHttpRequestResponseType
Returns void
response URL
-
get responseURL(): string
Returns client's response url
Returns string
status
-
get status(): number
Returns client's status
Returns number
status Text
-
get statusText(): string
Returns client's status as a text
Returns string
timeout
-
get timeout(): number
Gets or sets the timeout value in milliseconds
Returns number
-
set timeout(value: number): void
Parameters
- value: number
Returns void
StaticIs Custom Request Available
-
get IsCustomRequestAvailable(): boolean
This function can be called to check if there are request modifiers for network requests
Returns boolean
true if there are any custom requests available
Methods
abort
-
Cancels any network activity
Returns void
get Response Header
-
Get the string containing the text of a particular header's value.
Parameters
- name: string
The name of the header
Returns Nullable<string>
The string containing the text of the given header name
- name: string
open
-
Sets the request method, request URL
Parameters
- method: string
defines the method to use (GET, POST, etc..)
- url: string
defines the url to connect with
OptionalbaseHeaders: Record<string, string>optional headers to include as a base before applying CustomRequestHeaders and modifiers
Returns void
- method: string
send
-
Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
Parameters
Optionalbody: Document | XMLHttpRequestBodyInit | nulldefines an optional request body
Returns void
set Request Header
-
Sets the value of a request header.
Parameters
- name: string
The name of the header whose value is to be set
- value: string
The value to set as the body of the header
Returns void
- name: string
StaticFetch Async
-
FetchAsync(
url: string,
options?: {
body?: BodyInit | null;
headers?: Record<string, string>;
method?: string;
},
): Promise<Response>Performs a network request using the Fetch API when available on the platform, falling back to XMLHttpRequest.
WebRequest.CustomRequestHeadersandWebRequest.CustomRequestModifiersare applied in both cases.For
CustomRequestModifiers, a minimal proxy XHR is provided to each modifier so that calls tosetRequestHeaderon it are captured and forwarded to the underlying request. The URL returned by a modifier (if any) replaces the current URL before the next modifier runs.Parameters
- url: string
The URL to request.
- options: { body?: BodyInit | null; headers?: Record<string, string>; method?: string } = {}
Optional request options (method, headers, body).
Returns Promise<Response>
A Promise that resolves to a
Response. - url: string
Extended version of XMLHttpRequest with support for customizations (headers, ...)