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; keepalive?: boolean | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | 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; keepalive?: boolean | 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; keepalive?: boolean | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | 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; keepalive?: boolean | undefined; } | undefinedHttpRequeststringstringT | null{ headers?: HttpHeaders | undefined; context?: HttpContext | undefined; reportProgress?: boolean | undefined; params?: HttpParams | undefined; responseType?: "arraybuffer" | "blob" | "text" | "json" | undefined; withCredentials?: boolean | undefined; keepalive?: boolean | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | 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).
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.
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
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; keepalive?: boolean | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | 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; withCredentials?: boolean | undefined; transferCache?: boolean | { includeHeaders?: string[] | undefined; } | 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.