HttpRequest
class
An outgoing HTTP request with an optional typed body.
class HttpRequest<T> {
constructor(method: string, url: string, third?: T | { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; }, fourth?: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; })
body: T | null
headers: HttpHeaders
reportProgress: boolean
withCredentials: boolean
responseType: 'arraybuffer' | 'blob' | 'json' | 'text'
method: string
params: HttpParams
urlWithParams: string
url: string
serializeBody(): ArrayBuffer | Blob | FormData | string | null
detectContentTypeHeader(): string | null
clone(update: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; body?: any; method?: string; url?: string; setHeaders?: { ...; }; setParams?: { ...; }; } = {}): HttpRequest<any>
}
Description
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.
Constructor
3 overloads...Show All Hide All Overload #1constructor(method: "DELETE" | "GET" | "HEAD" | "JSONP" | "OPTIONS", url: string, init?: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; })Parameters
Overload #2constructor(method: "POST" | "PUT" | "PATCH", url: string, body: T, init?: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; })Parameters
Overload #3constructor(method: string, url: string, body: T, init?: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; })Parameters
|
Properties
Property | Description |
---|---|
null |
Read-Only
The request body, or 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: HttpHeaders
|
Read-Only Outgoing headers for this request. |
reportProgress: boolean
|
Read-Only Whether 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. |
withCredentials: boolean
|
Read-Only Whether this request should be sent with outgoing credentials (cookies). |
'blob' | 'json' | 'text' |
Read-Only The expected response type of the server. This is used to parse the response appropriately before returning it to the requestee. |
method: string
|
Read-Only The outgoing HTTP request method. |
params: HttpParams
|
Read-Only Outgoing URL parameters. |
urlWithParams: string
|
Read-Only The outgoing URL with all URL parameters set. |
url: string
|
Read-Only Declared in Constructor |
Methods
serializeBody() |
---|
Transform the free-form body into a serialized format suitable for transmission to the server. |
serializeBody(): ArrayBuffer | Blob | FormData | string | nullParametersThere are no parameters. Returns
|
detectContentTypeHeader() |
---|
Examine the body and attempt to infer an appropriate MIME type for it. |
detectContentTypeHeader(): string | nullParametersThere are no parameters. Returns
|
If no such type can be inferred, this method will return null .
|
clone() | ||||||
---|---|---|---|---|---|---|
3 overloads...Show All Hide All Overload #1clone(): HttpRequest<T>ParametersThere are no parameters. Returns
Overload #2clone(update: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; body?: T; method?: string; url?: string; setHeaders?: { ...; }; setParams?: { ...; }; }): HttpRequest<T>Parameters
Returns
Overload #3clone<V>(update: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; body?: V; method?: string; url?: string; setHeaders?: { ...; }; setParams?: { ...; }; }): HttpRequest<V>Parameters
Returns
|
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v8.angular.io/api/common/http/HttpRequest