@alterior/http 3.13.3 → 3.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend.d.ts +38 -38
- package/dist/backend.js +38 -38
- package/dist/client.d.ts +2108 -2108
- package/dist/client.js +265 -265
- package/dist/client.js.map +1 -1
- package/dist/headers.d.ts +57 -57
- package/dist/headers.js +187 -187
- package/dist/headers.js.map +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.js +42 -42
- package/dist/interceptor.d.ts +63 -63
- package/dist/interceptor.js +43 -43
- package/dist/interceptor.js.map +1 -1
- package/dist/module.d.ts +101 -101
- package/dist/module.js +188 -188
- package/dist/module.js.map +1 -1
- package/dist/params.d.ts +98 -98
- package/dist/params.js +184 -184
- package/dist/params.js.map +1 -1
- package/dist/request.d.ts +130 -130
- package/dist/request.js +260 -260
- package/dist/request.js.map +1 -1
- package/dist/response.d.ts +267 -267
- package/dist/response.js +165 -165
- package/dist/response.js.map +1 -1
- package/dist/server.d.ts +28 -28
- package/dist/server.js +119 -119
- package/dist/server.js.map +1 -1
- package/dist/test/client.test.d.ts +8 -8
- package/dist/test/client.test.js +163 -163
- package/dist/test/client.test.js.map +1 -1
- package/dist/test/headers.test.d.ts +1 -1
- package/dist/test/headers.test.js +126 -126
- package/dist/test/module.test.d.ts +1 -1
- package/dist/test/module.test.js +117 -117
- package/dist/test/module.test.js.map +1 -1
- package/dist/test/params.test.d.ts +1 -1
- package/dist/test/params.test.js +63 -63
- package/dist/test/request.test.d.ts +8 -8
- package/dist/test/request.test.js +159 -159
- package/dist/test/request.test.js.map +1 -1
- package/dist/test/response.test.d.ts +1 -1
- package/dist/test/response.test.js +79 -79
- package/dist/test/response.test.js.map +1 -1
- package/dist/test/test.d.ts +1 -1
- package/dist/test/test.js +16 -16
- package/dist/test/xhr.mock.d.ts +48 -48
- package/dist/test/xhr.mock.js +94 -94
- package/dist/test/xhr.mock.js.map +1 -1
- package/dist/test/xhr.test.d.ts +1 -1
- package/dist/test/xhr.test.js +344 -344
- package/dist/test/xhr.test.js.map +1 -1
- package/dist/test/xsrf.test.d.ts +1 -1
- package/dist/test/xsrf.test.js +63 -63
- package/dist/test/xsrf.test.js.map +1 -1
- package/dist/testing/api.d.ts +102 -102
- package/dist/testing/api.js +19 -19
- package/dist/testing/backend.d.ts +63 -63
- package/dist/testing/backend.js +141 -141
- package/dist/testing/backend.js.map +1 -1
- package/dist/testing/index.d.ts +10 -10
- package/dist/testing/index.js +16 -16
- package/dist/testing/module.d.ts +16 -16
- package/dist/testing/module.js +38 -38
- package/dist/testing/module.js.map +1 -1
- package/dist/testing/request.d.ts +56 -56
- package/dist/testing/request.js +177 -177
- package/dist/testing/request.js.map +1 -1
- package/dist/testing/request.test.d.ts +8 -8
- package/dist/testing/request.test.js +24 -24
- package/dist/xhr.d.ts +42 -42
- package/dist/xhr.js +298 -298
- package/dist/xhr.js.map +1 -1
- package/dist/xsrf.d.ts +37 -37
- package/dist/xsrf.js +55 -55
- package/dist/xsrf.js.map +1 -1
- package/dist.esm/backend.d.ts +38 -38
- package/dist.esm/backend.js +33 -33
- package/dist.esm/client.d.ts +2108 -2108
- package/dist.esm/client.js +262 -262
- package/dist.esm/client.js.map +1 -1
- package/dist.esm/headers.d.ts +57 -57
- package/dist.esm/headers.js +183 -183
- package/dist.esm/headers.js.map +1 -1
- package/dist.esm/index.d.ts +18 -18
- package/dist.esm/index.js +18 -18
- package/dist.esm/interceptor.d.ts +63 -63
- package/dist.esm/interceptor.js +39 -39
- package/dist.esm/interceptor.js.map +1 -1
- package/dist.esm/module.d.ts +101 -101
- package/dist.esm/module.js +183 -183
- package/dist.esm/module.js.map +1 -1
- package/dist.esm/params.d.ts +98 -98
- package/dist.esm/params.js +179 -179
- package/dist.esm/params.js.map +1 -1
- package/dist.esm/request.d.ts +130 -130
- package/dist.esm/request.js +256 -256
- package/dist.esm/request.js.map +1 -1
- package/dist.esm/response.d.ts +267 -267
- package/dist.esm/response.js +158 -158
- package/dist.esm/response.js.map +1 -1
- package/dist.esm/server.d.ts +28 -28
- package/dist.esm/server.js +113 -113
- package/dist.esm/server.js.map +1 -1
- package/dist.esm/test/client.test.d.ts +8 -8
- package/dist.esm/test/client.test.js +161 -161
- package/dist.esm/test/client.test.js.map +1 -1
- package/dist.esm/test/headers.test.d.ts +1 -1
- package/dist.esm/test/headers.test.js +124 -124
- package/dist.esm/test/module.test.d.ts +1 -1
- package/dist.esm/test/module.test.js +115 -115
- package/dist.esm/test/module.test.js.map +1 -1
- package/dist.esm/test/params.test.d.ts +1 -1
- package/dist.esm/test/params.test.js +61 -61
- package/dist.esm/test/request.test.d.ts +8 -8
- package/dist.esm/test/request.test.js +157 -157
- package/dist.esm/test/request.test.js.map +1 -1
- package/dist.esm/test/response.test.d.ts +1 -1
- package/dist.esm/test/response.test.js +77 -77
- package/dist.esm/test/response.test.js.map +1 -1
- package/dist.esm/test/test.d.ts +1 -1
- package/dist.esm/test/test.js +14 -14
- package/dist.esm/test/xhr.mock.d.ts +48 -48
- package/dist.esm/test/xhr.mock.js +88 -88
- package/dist.esm/test/xhr.mock.js.map +1 -1
- package/dist.esm/test/xhr.test.d.ts +1 -1
- package/dist.esm/test/xhr.test.js +342 -342
- package/dist.esm/test/xhr.test.js.map +1 -1
- package/dist.esm/test/xsrf.test.d.ts +1 -1
- package/dist.esm/test/xsrf.test.js +61 -61
- package/dist.esm/test/xsrf.test.js.map +1 -1
- package/dist.esm/testing/api.d.ts +102 -102
- package/dist.esm/testing/api.js +15 -15
- package/dist.esm/testing/backend.d.ts +63 -63
- package/dist.esm/testing/backend.js +138 -138
- package/dist.esm/testing/backend.js.map +1 -1
- package/dist.esm/testing/index.d.ts +10 -10
- package/dist.esm/testing/index.js +10 -10
- package/dist.esm/testing/module.d.ts +16 -16
- package/dist.esm/testing/module.js +35 -35
- package/dist.esm/testing/module.js.map +1 -1
- package/dist.esm/testing/request.d.ts +56 -56
- package/dist.esm/testing/request.js +173 -173
- package/dist.esm/testing/request.js.map +1 -1
- package/dist.esm/testing/request.test.d.ts +8 -8
- package/dist.esm/testing/request.test.js +22 -22
- package/dist.esm/xhr.d.ts +42 -42
- package/dist.esm/xhr.js +294 -294
- package/dist.esm/xhr.js.map +1 -1
- package/dist.esm/xsrf.d.ts +37 -37
- package/dist.esm/xsrf.js +51 -51
- package/dist.esm/xsrf.js.map +1 -1
- package/package.json +9 -9
- package/tsconfig.esm.tsbuildinfo +1 -0
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -8046
package/dist.esm/response.d.ts
CHANGED
|
@@ -1,268 +1,268 @@
|
|
|
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
|
-
/**
|
|
10
|
-
* Type enumeration for the different kinds of `HttpEvent`.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export declare enum HttpEventType {
|
|
15
|
-
/**
|
|
16
|
-
* The request was sent out over the wire.
|
|
17
|
-
*/
|
|
18
|
-
Sent = 0,
|
|
19
|
-
/**
|
|
20
|
-
* An upload progress event was received.
|
|
21
|
-
*/
|
|
22
|
-
UploadProgress = 1,
|
|
23
|
-
/**
|
|
24
|
-
* The response status code and headers were received.
|
|
25
|
-
*/
|
|
26
|
-
ResponseHeader = 2,
|
|
27
|
-
/**
|
|
28
|
-
* A download progress event was received.
|
|
29
|
-
*/
|
|
30
|
-
DownloadProgress = 3,
|
|
31
|
-
/**
|
|
32
|
-
* The full response including the body was received.
|
|
33
|
-
*/
|
|
34
|
-
Response = 4,
|
|
35
|
-
/**
|
|
36
|
-
* A custom event from an interceptor or a backend.
|
|
37
|
-
*/
|
|
38
|
-
User = 5
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Base interface for progress events.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
export interface HttpProgressEvent {
|
|
46
|
-
/**
|
|
47
|
-
* Progress event type is either upload or download.
|
|
48
|
-
*/
|
|
49
|
-
type: HttpEventType.DownloadProgress | HttpEventType.UploadProgress;
|
|
50
|
-
/**
|
|
51
|
-
* Number of bytes uploaded or downloaded.
|
|
52
|
-
*/
|
|
53
|
-
loaded: number;
|
|
54
|
-
/**
|
|
55
|
-
* Total number of bytes to upload or download. Depending on the request or
|
|
56
|
-
* response, this may not be computable and thus may not be present.
|
|
57
|
-
*/
|
|
58
|
-
total?: number;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* A download progress event.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
export interface HttpDownloadProgressEvent extends HttpProgressEvent {
|
|
66
|
-
type: HttpEventType.DownloadProgress;
|
|
67
|
-
/**
|
|
68
|
-
* The partial response body as downloaded so far.
|
|
69
|
-
*
|
|
70
|
-
* Only present if the responseType was `text`.
|
|
71
|
-
*/
|
|
72
|
-
partialText?: string;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* An upload progress event.
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*/
|
|
79
|
-
export interface HttpUploadProgressEvent extends HttpProgressEvent {
|
|
80
|
-
type: HttpEventType.UploadProgress;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* An event indicating that the request was sent to the server. Useful
|
|
84
|
-
* when a request may be retried multiple times, to distinguish between
|
|
85
|
-
* retries on the final event stream.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*/
|
|
89
|
-
export interface HttpSentEvent {
|
|
90
|
-
type: HttpEventType.Sent;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* A user-defined event.
|
|
94
|
-
*
|
|
95
|
-
* Grouping all custom events under this type ensures they will be handled
|
|
96
|
-
* and forwarded by all implementations of interceptors.
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
export interface HttpUserEvent<T> {
|
|
101
|
-
type: HttpEventType.User;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* An error that represents a failed attempt to JSON.parse text coming back
|
|
105
|
-
* from the server.
|
|
106
|
-
*
|
|
107
|
-
* It bundles the Error object with the actual response body that failed to parse.
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
export interface HttpJsonParseError {
|
|
112
|
-
error: Error;
|
|
113
|
-
text: string;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Union type for all possible events on the response stream.
|
|
117
|
-
*
|
|
118
|
-
* Typed according to the expected type of the response.
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*/
|
|
122
|
-
export type HttpEvent<T> = HttpSentEvent | HttpHeaderResponse | HttpResponse<T> | HttpProgressEvent | HttpUserEvent<T>;
|
|
123
|
-
/**
|
|
124
|
-
* Base class for both `HttpResponse` and `HttpHeaderResponse`.
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*/
|
|
128
|
-
export declare abstract class HttpResponseBase {
|
|
129
|
-
/**
|
|
130
|
-
* All response headers.
|
|
131
|
-
*/
|
|
132
|
-
readonly headers: HttpHeaders;
|
|
133
|
-
/**
|
|
134
|
-
* Response status code.
|
|
135
|
-
*/
|
|
136
|
-
readonly status: number;
|
|
137
|
-
/**
|
|
138
|
-
* Textual description of response status code.
|
|
139
|
-
*
|
|
140
|
-
* Do not depend on this.
|
|
141
|
-
*/
|
|
142
|
-
readonly statusText: string;
|
|
143
|
-
/**
|
|
144
|
-
* URL of the resource retrieved, or null if not available.
|
|
145
|
-
*/
|
|
146
|
-
readonly url: string | null;
|
|
147
|
-
/**
|
|
148
|
-
* Whether the status code falls in the 2xx range.
|
|
149
|
-
*/
|
|
150
|
-
readonly ok: boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Type of the response, narrowed to either the full response or the header.
|
|
153
|
-
*/
|
|
154
|
-
readonly type: HttpEventType.Response | HttpEventType.ResponseHeader;
|
|
155
|
-
/**
|
|
156
|
-
* Super-constructor for all responses.
|
|
157
|
-
*
|
|
158
|
-
* The single parameter accepted is an initialization hash. Any properties
|
|
159
|
-
* of the response passed there will override the default values.
|
|
160
|
-
*/
|
|
161
|
-
constructor(init: {
|
|
162
|
-
headers?: HttpHeaders;
|
|
163
|
-
status?: number;
|
|
164
|
-
statusText?: string;
|
|
165
|
-
url?: string;
|
|
166
|
-
}, defaultStatus?: number, defaultStatusText?: string);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* A partial HTTP response which only includes the status and header data,
|
|
170
|
-
* but no response body.
|
|
171
|
-
*
|
|
172
|
-
* `HttpHeaderResponse` is a `HttpEvent` available on the response
|
|
173
|
-
* event stream, only when progress events are requested.
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*/
|
|
177
|
-
export declare class HttpHeaderResponse extends HttpResponseBase {
|
|
178
|
-
/**
|
|
179
|
-
* Create a new `HttpHeaderResponse` with the given parameters.
|
|
180
|
-
*/
|
|
181
|
-
constructor(init?: {
|
|
182
|
-
headers?: HttpHeaders;
|
|
183
|
-
status?: number;
|
|
184
|
-
statusText?: string;
|
|
185
|
-
url?: string;
|
|
186
|
-
});
|
|
187
|
-
readonly type: HttpEventType.ResponseHeader;
|
|
188
|
-
/**
|
|
189
|
-
* Copy this `HttpHeaderResponse`, overriding its contents with the
|
|
190
|
-
* given parameter hash.
|
|
191
|
-
*/
|
|
192
|
-
clone(update?: {
|
|
193
|
-
headers?: HttpHeaders;
|
|
194
|
-
status?: number;
|
|
195
|
-
statusText?: string;
|
|
196
|
-
url?: string;
|
|
197
|
-
}): HttpHeaderResponse;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* A full HTTP response, including a typed response body (which may be `null`
|
|
201
|
-
* if one was not returned).
|
|
202
|
-
*
|
|
203
|
-
* `HttpResponse` is a `HttpEvent` available on the response event
|
|
204
|
-
* stream.
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*/
|
|
208
|
-
export declare class HttpResponse<T> extends HttpResponseBase {
|
|
209
|
-
/**
|
|
210
|
-
* The response body, or `null` if one was not returned.
|
|
211
|
-
*/
|
|
212
|
-
readonly body: T | null;
|
|
213
|
-
/**
|
|
214
|
-
* Construct a new `HttpResponse`.
|
|
215
|
-
*/
|
|
216
|
-
constructor(init?: {
|
|
217
|
-
body?: T | null;
|
|
218
|
-
headers?: HttpHeaders;
|
|
219
|
-
status?: number;
|
|
220
|
-
statusText?: string;
|
|
221
|
-
url?: string;
|
|
222
|
-
});
|
|
223
|
-
readonly type: HttpEventType.Response;
|
|
224
|
-
clone(): HttpResponse<T>;
|
|
225
|
-
clone(update: {
|
|
226
|
-
headers?: HttpHeaders;
|
|
227
|
-
status?: number;
|
|
228
|
-
statusText?: string;
|
|
229
|
-
url?: string;
|
|
230
|
-
}): HttpResponse<T>;
|
|
231
|
-
clone<V>(update: {
|
|
232
|
-
body?: V | null;
|
|
233
|
-
headers?: HttpHeaders;
|
|
234
|
-
status?: number;
|
|
235
|
-
statusText?: string;
|
|
236
|
-
url?: string;
|
|
237
|
-
}): HttpResponse<V>;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* A response that represents an error or failure, either from a
|
|
241
|
-
* non-successful HTTP status, an error while executing the request,
|
|
242
|
-
* or some other failure which occurred during the parsing of the response.
|
|
243
|
-
*
|
|
244
|
-
* Any error returned on the `Observable` response stream will be
|
|
245
|
-
* wrapped in an `HttpErrorResponse` to provide additional context about
|
|
246
|
-
* the state of the HTTP layer when the error occurred. The error property
|
|
247
|
-
* will contain either a wrapped Error object or the error response returned
|
|
248
|
-
* from the server.
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*/
|
|
252
|
-
export declare class HttpErrorResponse extends HttpResponseBase implements Error {
|
|
253
|
-
readonly name = "HttpErrorResponse";
|
|
254
|
-
readonly message: string;
|
|
255
|
-
readonly error: any | null;
|
|
256
|
-
/**
|
|
257
|
-
* Errors are never okay, even when the status code is in the 2xx success range.
|
|
258
|
-
*/
|
|
259
|
-
readonly ok = false;
|
|
260
|
-
constructor(init: {
|
|
261
|
-
error?: any;
|
|
262
|
-
headers?: HttpHeaders;
|
|
263
|
-
status?: number;
|
|
264
|
-
statusText?: string;
|
|
265
|
-
url?: string;
|
|
266
|
-
});
|
|
267
|
-
}
|
|
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
|
+
/**
|
|
10
|
+
* Type enumeration for the different kinds of `HttpEvent`.
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare enum HttpEventType {
|
|
15
|
+
/**
|
|
16
|
+
* The request was sent out over the wire.
|
|
17
|
+
*/
|
|
18
|
+
Sent = 0,
|
|
19
|
+
/**
|
|
20
|
+
* An upload progress event was received.
|
|
21
|
+
*/
|
|
22
|
+
UploadProgress = 1,
|
|
23
|
+
/**
|
|
24
|
+
* The response status code and headers were received.
|
|
25
|
+
*/
|
|
26
|
+
ResponseHeader = 2,
|
|
27
|
+
/**
|
|
28
|
+
* A download progress event was received.
|
|
29
|
+
*/
|
|
30
|
+
DownloadProgress = 3,
|
|
31
|
+
/**
|
|
32
|
+
* The full response including the body was received.
|
|
33
|
+
*/
|
|
34
|
+
Response = 4,
|
|
35
|
+
/**
|
|
36
|
+
* A custom event from an interceptor or a backend.
|
|
37
|
+
*/
|
|
38
|
+
User = 5
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Base interface for progress events.
|
|
42
|
+
*
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
export interface HttpProgressEvent {
|
|
46
|
+
/**
|
|
47
|
+
* Progress event type is either upload or download.
|
|
48
|
+
*/
|
|
49
|
+
type: HttpEventType.DownloadProgress | HttpEventType.UploadProgress;
|
|
50
|
+
/**
|
|
51
|
+
* Number of bytes uploaded or downloaded.
|
|
52
|
+
*/
|
|
53
|
+
loaded: number;
|
|
54
|
+
/**
|
|
55
|
+
* Total number of bytes to upload or download. Depending on the request or
|
|
56
|
+
* response, this may not be computable and thus may not be present.
|
|
57
|
+
*/
|
|
58
|
+
total?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A download progress event.
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
export interface HttpDownloadProgressEvent extends HttpProgressEvent {
|
|
66
|
+
type: HttpEventType.DownloadProgress;
|
|
67
|
+
/**
|
|
68
|
+
* The partial response body as downloaded so far.
|
|
69
|
+
*
|
|
70
|
+
* Only present if the responseType was `text`.
|
|
71
|
+
*/
|
|
72
|
+
partialText?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* An upload progress event.
|
|
76
|
+
*
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
export interface HttpUploadProgressEvent extends HttpProgressEvent {
|
|
80
|
+
type: HttpEventType.UploadProgress;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* An event indicating that the request was sent to the server. Useful
|
|
84
|
+
* when a request may be retried multiple times, to distinguish between
|
|
85
|
+
* retries on the final event stream.
|
|
86
|
+
*
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
export interface HttpSentEvent {
|
|
90
|
+
type: HttpEventType.Sent;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A user-defined event.
|
|
94
|
+
*
|
|
95
|
+
* Grouping all custom events under this type ensures they will be handled
|
|
96
|
+
* and forwarded by all implementations of interceptors.
|
|
97
|
+
*
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
export interface HttpUserEvent<T> {
|
|
101
|
+
type: HttpEventType.User;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* An error that represents a failed attempt to JSON.parse text coming back
|
|
105
|
+
* from the server.
|
|
106
|
+
*
|
|
107
|
+
* It bundles the Error object with the actual response body that failed to parse.
|
|
108
|
+
*
|
|
109
|
+
*
|
|
110
|
+
*/
|
|
111
|
+
export interface HttpJsonParseError {
|
|
112
|
+
error: Error;
|
|
113
|
+
text: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Union type for all possible events on the response stream.
|
|
117
|
+
*
|
|
118
|
+
* Typed according to the expected type of the response.
|
|
119
|
+
*
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
export type HttpEvent<T> = HttpSentEvent | HttpHeaderResponse | HttpResponse<T> | HttpProgressEvent | HttpUserEvent<T>;
|
|
123
|
+
/**
|
|
124
|
+
* Base class for both `HttpResponse` and `HttpHeaderResponse`.
|
|
125
|
+
*
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
export declare abstract class HttpResponseBase {
|
|
129
|
+
/**
|
|
130
|
+
* All response headers.
|
|
131
|
+
*/
|
|
132
|
+
readonly headers: HttpHeaders;
|
|
133
|
+
/**
|
|
134
|
+
* Response status code.
|
|
135
|
+
*/
|
|
136
|
+
readonly status: number;
|
|
137
|
+
/**
|
|
138
|
+
* Textual description of response status code.
|
|
139
|
+
*
|
|
140
|
+
* Do not depend on this.
|
|
141
|
+
*/
|
|
142
|
+
readonly statusText: string;
|
|
143
|
+
/**
|
|
144
|
+
* URL of the resource retrieved, or null if not available.
|
|
145
|
+
*/
|
|
146
|
+
readonly url: string | null;
|
|
147
|
+
/**
|
|
148
|
+
* Whether the status code falls in the 2xx range.
|
|
149
|
+
*/
|
|
150
|
+
readonly ok: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Type of the response, narrowed to either the full response or the header.
|
|
153
|
+
*/
|
|
154
|
+
readonly type: HttpEventType.Response | HttpEventType.ResponseHeader;
|
|
155
|
+
/**
|
|
156
|
+
* Super-constructor for all responses.
|
|
157
|
+
*
|
|
158
|
+
* The single parameter accepted is an initialization hash. Any properties
|
|
159
|
+
* of the response passed there will override the default values.
|
|
160
|
+
*/
|
|
161
|
+
constructor(init: {
|
|
162
|
+
headers?: HttpHeaders;
|
|
163
|
+
status?: number;
|
|
164
|
+
statusText?: string;
|
|
165
|
+
url?: string;
|
|
166
|
+
}, defaultStatus?: number, defaultStatusText?: string);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A partial HTTP response which only includes the status and header data,
|
|
170
|
+
* but no response body.
|
|
171
|
+
*
|
|
172
|
+
* `HttpHeaderResponse` is a `HttpEvent` available on the response
|
|
173
|
+
* event stream, only when progress events are requested.
|
|
174
|
+
*
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
177
|
+
export declare class HttpHeaderResponse extends HttpResponseBase {
|
|
178
|
+
/**
|
|
179
|
+
* Create a new `HttpHeaderResponse` with the given parameters.
|
|
180
|
+
*/
|
|
181
|
+
constructor(init?: {
|
|
182
|
+
headers?: HttpHeaders;
|
|
183
|
+
status?: number;
|
|
184
|
+
statusText?: string;
|
|
185
|
+
url?: string;
|
|
186
|
+
});
|
|
187
|
+
readonly type: HttpEventType.ResponseHeader;
|
|
188
|
+
/**
|
|
189
|
+
* Copy this `HttpHeaderResponse`, overriding its contents with the
|
|
190
|
+
* given parameter hash.
|
|
191
|
+
*/
|
|
192
|
+
clone(update?: {
|
|
193
|
+
headers?: HttpHeaders;
|
|
194
|
+
status?: number;
|
|
195
|
+
statusText?: string;
|
|
196
|
+
url?: string;
|
|
197
|
+
}): HttpHeaderResponse;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A full HTTP response, including a typed response body (which may be `null`
|
|
201
|
+
* if one was not returned).
|
|
202
|
+
*
|
|
203
|
+
* `HttpResponse` is a `HttpEvent` available on the response event
|
|
204
|
+
* stream.
|
|
205
|
+
*
|
|
206
|
+
*
|
|
207
|
+
*/
|
|
208
|
+
export declare class HttpResponse<T> extends HttpResponseBase {
|
|
209
|
+
/**
|
|
210
|
+
* The response body, or `null` if one was not returned.
|
|
211
|
+
*/
|
|
212
|
+
readonly body: T | null;
|
|
213
|
+
/**
|
|
214
|
+
* Construct a new `HttpResponse`.
|
|
215
|
+
*/
|
|
216
|
+
constructor(init?: {
|
|
217
|
+
body?: T | null;
|
|
218
|
+
headers?: HttpHeaders;
|
|
219
|
+
status?: number;
|
|
220
|
+
statusText?: string;
|
|
221
|
+
url?: string;
|
|
222
|
+
});
|
|
223
|
+
readonly type: HttpEventType.Response;
|
|
224
|
+
clone(): HttpResponse<T>;
|
|
225
|
+
clone(update: {
|
|
226
|
+
headers?: HttpHeaders;
|
|
227
|
+
status?: number;
|
|
228
|
+
statusText?: string;
|
|
229
|
+
url?: string;
|
|
230
|
+
}): HttpResponse<T>;
|
|
231
|
+
clone<V>(update: {
|
|
232
|
+
body?: V | null;
|
|
233
|
+
headers?: HttpHeaders;
|
|
234
|
+
status?: number;
|
|
235
|
+
statusText?: string;
|
|
236
|
+
url?: string;
|
|
237
|
+
}): HttpResponse<V>;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* A response that represents an error or failure, either from a
|
|
241
|
+
* non-successful HTTP status, an error while executing the request,
|
|
242
|
+
* or some other failure which occurred during the parsing of the response.
|
|
243
|
+
*
|
|
244
|
+
* Any error returned on the `Observable` response stream will be
|
|
245
|
+
* wrapped in an `HttpErrorResponse` to provide additional context about
|
|
246
|
+
* the state of the HTTP layer when the error occurred. The error property
|
|
247
|
+
* will contain either a wrapped Error object or the error response returned
|
|
248
|
+
* from the server.
|
|
249
|
+
*
|
|
250
|
+
*
|
|
251
|
+
*/
|
|
252
|
+
export declare class HttpErrorResponse extends HttpResponseBase implements Error {
|
|
253
|
+
readonly name = "HttpErrorResponse";
|
|
254
|
+
readonly message: string;
|
|
255
|
+
readonly error: any | null;
|
|
256
|
+
/**
|
|
257
|
+
* Errors are never okay, even when the status code is in the 2xx success range.
|
|
258
|
+
*/
|
|
259
|
+
readonly ok = false;
|
|
260
|
+
constructor(init: {
|
|
261
|
+
error?: any;
|
|
262
|
+
headers?: HttpHeaders;
|
|
263
|
+
status?: number;
|
|
264
|
+
statusText?: string;
|
|
265
|
+
url?: string;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
268
|
//# sourceMappingURL=response.d.ts.map
|