1
|
/**
|
2
|
* @license
|
3
|
* Copyright Google Inc. All Rights Reserved.
|
4
|
*
|
5
|
* Use of this source code is governed by an MIT-style license that can be
|
6
|
* found in the LICENSE file at https://angular.io/license
|
7
|
*/
|
8
|
import { HttpHeaders } from './headers';
|
9
|
import { HttpParams } from './params';
|
10
|
/**
|
11
|
* An outgoing HTTP request with an optional typed body.
|
12
|
*
|
13
|
* `HttpRequest` represents an outgoing request, including URL, method,
|
14
|
* headers, body, and other request configuration options. Instances should be
|
15
|
* assumed to be immutable. To modify a `HttpRequest`, the `clone`
|
16
|
* method should be used.
|
17
|
*
|
18
|
* @experimental
|
19
|
*/
|
20
|
export declare class HttpRequest<T> {
|
21
|
readonly url: string;
|
22
|
/**
|
23
|
* The request body, or `null` if one isn't set.
|
24
|
*
|
25
|
* Bodies are not enforced to be immutable, as they can include a reference to any
|
26
|
* user-defined data type. However, interceptors should take care to preserve
|
27
|
* idempotence by treating them as such.
|
28
|
*/
|
29
|
readonly body: T | null;
|
30
|
/**
|
31
|
* Outgoing headers for this request.
|
32
|
*/
|
33
|
readonly headers: HttpHeaders;
|
34
|
/**
|
35
|
* Whether this request should be made in a way that exposes progress events.
|
36
|
*
|
37
|
* Progress events are expensive (change detection runs on each event) and so
|
38
|
* they should only be requested if the consumer intends to monitor them.
|
39
|
*/
|
40
|
readonly reportProgress: boolean;
|
41
|
/**
|
42
|
* Whether this request should be sent with outgoing credentials (cookies).
|
43
|
*/
|
44
|
readonly withCredentials: boolean;
|
45
|
/**
|
46
|
* The expected response type of the server.
|
47
|
*
|
48
|
* This is used to parse the response appropriately before returning it to
|
49
|
* the requestee.
|
50
|
*/
|
51
|
readonly responseType: 'arraybuffer' | 'blob' | 'json' | 'text';
|
52
|
/**
|
53
|
* The outgoing HTTP request method.
|
54
|
*/
|
55
|
readonly method: string;
|
56
|
/**
|
57
|
* Outgoing URL parameters.
|
58
|
*/
|
59
|
readonly params: HttpParams;
|
60
|
/**
|
61
|
* The outgoing URL with all URL parameters set.
|
62
|
*/
|
63
|
readonly urlWithParams: string;
|
64
|
constructor(method: 'DELETE' | 'GET' | 'HEAD' | 'JSONP' | 'OPTIONS', url: string, init?: {
|
65
|
headers?: HttpHeaders;
|
66
|
reportProgress?: boolean;
|
67
|
params?: HttpParams;
|
68
|
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
69
|
withCredentials?: boolean;
|
70
|
});
|
71
|
constructor(method: 'POST' | 'PUT' | 'PATCH', url: string, body: T | null, init?: {
|
72
|
headers?: HttpHeaders;
|
73
|
reportProgress?: boolean;
|
74
|
params?: HttpParams;
|
75
|
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
76
|
withCredentials?: boolean;
|
77
|
});
|
78
|
constructor(method: string, url: string, body: T | null, init?: {
|
79
|
headers?: HttpHeaders;
|
80
|
reportProgress?: boolean;
|
81
|
params?: HttpParams;
|
82
|
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
83
|
withCredentials?: boolean;
|
84
|
});
|
85
|
/**
|
86
|
* Transform the free-form body into a serialized format suitable for
|
87
|
* transmission to the server.
|
88
|
*/
|
89
|
serializeBody(): ArrayBuffer | Blob | FormData | string | null;
|
90
|
/**
|
91
|
* Examine the body and attempt to infer an appropriate MIME type
|
92
|
* for it.
|
93
|
*
|
94
|
* If no such type can be inferred, this method will return `null`.
|
95
|
*/
|
96
|
detectContentTypeHeader(): string | null;
|
97
|
clone(): HttpRequest<T>;
|
98
|
clone(update: {
|
99
|
headers?: HttpHeaders;
|
100
|
reportProgress?: boolean;
|
101
|
params?: HttpParams;
|
102
|
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
103
|
withCredentials?: boolean;
|
104
|
body?: T | null;
|
105
|
method?: string;
|
106
|
url?: string;
|
107
|
setHeaders?: {
|
108
|
[name: string]: string | string[];
|
109
|
};
|
110
|
setParams?: {
|
111
|
[param: string]: string;
|
112
|
};
|
113
|
}): HttpRequest<T>;
|
114
|
clone<V>(update: {
|
115
|
headers?: HttpHeaders;
|
116
|
reportProgress?: boolean;
|
117
|
params?: HttpParams;
|
118
|
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
|
119
|
withCredentials?: boolean;
|
120
|
body?: V | null;
|
121
|
method?: string;
|
122
|
url?: string;
|
123
|
setHeaders?: {
|
124
|
[name: string]: string | string[];
|
125
|
};
|
126
|
setParams?: {
|
127
|
[param: string]: string;
|
128
|
};
|
129
|
}): HttpRequest<V>;
|
130
|
}
|