HttpRequest
An outgoing HTTP request with an optional typed body.
constructor
5 overloads"GET" | "HEAD"string{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; withCredentials?: boolean | undefined; credentials?: RequestCredentials | undefined; keepalive?: boolean | undefined; priority?: RequestPriority | undefined; cache?: RequestCache | undefined; mode?: RequestMode | undefined; redirect?: RequestRedirect | undefined; referrer?: string | undefined; integrity?: string | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | undefined; timeout?: number | undefined; } | undefinedHttpRequest"DELETE" | "JSONP" | "OPTIONS"string{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; withCredentials?: boolean | undefined; credentials?: RequestCredentials | undefined; keepalive?: boolean | undefined; priority?: RequestPriority | undefined; cache?: RequestCache | undefined; timeout?: number | undefined; mode?: RequestMode | undefined; redirect?: RequestRedirect | undefined; referrer?: string | undefined; integrity?: string | undefined; } | undefinedHttpRequest"POST"stringT | null{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; withCredentials?: boolean | undefined; credentials?: RequestCredentials | undefined; keepalive?: boolean | undefined; priority?: RequestPriority | undefined; cache?: RequestCache | undefined; mode?: RequestMode | undefined; redirect?: RequestRedirect | undefined; referrer?: string | undefined; integrity?: string | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | undefined; timeout?: number | undefined; } | undefinedHttpRequest"PUT" | "PATCH"stringT | null{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; withCredentials?: boolean | undefined; credentials?: RequestCredentials | undefined; keepalive?: boolean | undefined; priority?: RequestPriority | undefined; cache?: RequestCache | undefined; timeout?: number | undefined; mode?: RequestMode | undefined; redirect?: RequestRedirect | undefined; referrer?: string | undefined; integrity?: string | undefined; } | undefinedHttpRequeststringstringT | null{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; withCredentials?: boolean | undefined; credentials?: RequestCredentials | undefined; keepalive?: boolean | undefined; priority?: RequestPriority | undefined; cache?: RequestCache | undefined; mode?: RequestMode | undefined; redirect?: RequestRedirect | undefined; referrer?: string | undefined; integrity?: string | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | undefined; timeout?: number | undefined; } | undefinedHttpRequestbody
T | nullThe request body, or null if one isn't set.
Bodies are not enforced to be immutable, as they can include a reference to any user-defined data type. However, interceptors should take care to preserve idempotence by treating them as such.
headers
HttpHeadersOutgoing headers for this request.
context
HttpContextShared and mutable context that can be used by interceptors
reportProgress
booleanWhether this request should be made in a way that exposes progress events.
Progress events are expensive (change detection runs on each event) and so they should only be requested if the consumer intends to monitor them.
Note: The FetchBackend doesn't support progress report on uploads.
withCredentials
booleanWhether this request should be sent with outgoing credentials (cookies).
credentials
RequestCredentialsThe credentials mode of the request, which determines how cookies and HTTP authentication are handled. This can affect whether cookies are sent with the request, and how authentication is handled.
keepalive
booleanWhen using the fetch implementation and set to true, the browser will not abort the associated request if the page that initiated it is unloaded before the request is complete.
cache
RequestCacheControls how the request will interact with the browser's HTTP cache. This affects whether a response is retrieved from the cache, how it is stored, or if it bypasses the cache altogether.
priority
RequestPriorityIndicates the relative priority of the request. This may be used by the browser to decide the order in which requests are dispatched and resources fetched.
mode
RequestModeThe mode of the request, which determines how the request will interact with the browser's security model. This can affect things like CORS (Cross-Origin Resource Sharing) and same-origin policies.
redirect
RequestRedirectThe redirect mode of the request, which determines how redirects are handled. This can affect whether the request follows redirects automatically, or if it fails when a redirect occurs.
referrer
stringThe referrer of the request, which can be used to indicate the origin of the request. This is useful for security and analytics purposes. Value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
integrity
stringThe integrity metadata of the request, which can be used to ensure the request is made with the expected content. A cryptographic hash of the resource to be fetched by request
responseType
"arraybuffer" | "blob" | "text" | "json"The expected response type of the server.
This is used to parse the response appropriately before returning it to the requestee.
method
stringThe outgoing HTTP request method.
params
HttpParamsOutgoing URL parameters.
To pass a string representation of HTTP parameters in the URL-query-string format,
the HttpParamsOptions' fromString may be used. For example:
new HttpParams({fromString: 'angular=awesome'})
urlWithParams
stringThe outgoing URL with all URL parameters set.
transferCache
boolean | { includeHeaders?: string[] | undefined; } | undefinedThe HttpTransferCache option for the request
timeout
number | undefinedThe timeout for the backend HTTP request in ms.
serializeBody
string | ArrayBuffer | Blob | FormData | URLSearchParams | nullTransform the free-form body into a serialized format suitable for transmission to the server.
string | ArrayBuffer | Blob | FormData | URLSearchParams | nulldetectContentTypeHeader
string | nullExamine the body and attempt to infer an appropriate MIME type for it.
If no such type can be inferred, this method will return null.
string | nullclone
3 overloadsHttpRequest<T>{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; withCredentials?: boolean | undefined; credentials?: RequestCredentials | undefined; keepalive?: boolean | undefined; priority?: RequestPriority | undefined; cache?: RequestCache | undefined; mode?: RequestMode | undefined; redirect?: RequestRedirect | undefined; referrer?: string | undefined; integrity?: string | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | undefined; timeout?: number | undefined; body?: T | null | undefined; method?: string | undefined; url?: string | undefined; setHeaders?: { [name: string]: string | string[]; } | undefined; setParams?: { [param: string]: string; } | undefined; }HttpRequest<T>{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; keepalive?: boolean | undefined; priority?: RequestPriority | undefined; cache?: RequestCache | undefined; mode?: RequestMode | undefined; redirect?: RequestRedirect | undefined; referrer?: string | undefined; integrity?: string | undefined; withCredentials?: boolean | undefined; credentials?: RequestCredentials | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | undefined; timeout?: number | undefined; body?: V | null | undefined; method?: string | undefined; url?: string | undefined; setHeaders?: { [name: string]: string | string[]; } | undefined; setParams?: { [param: string]: string; } | undefined; }HttpRequest<V>Description
An outgoing HTTP request with an optional typed body.
HttpRequest represents an outgoing request, including URL, method,
headers, body, and other request configuration options. Instances should be
assumed to be immutable. To modify a HttpRequest, the clone
method should be used.