forked from angular/angular
/
http.d.ts
257 lines (229 loc) · 7.08 KB
/
http.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/** @experimental */
export declare class BaseRequestOptions extends RequestOptions {
constructor();
}
/** @experimental */
export declare class BaseResponseOptions extends ResponseOptions {
constructor();
}
/** @experimental */
export declare class BrowserXhr {
constructor();
build(): any;
}
/** @experimental */
export declare abstract class Connection {
readyState: ReadyState;
request: Request;
response: any;
}
/** @experimental */
export declare abstract class ConnectionBackend {
abstract createConnection(request: any): Connection;
}
/** @experimental */
export declare class CookieXSRFStrategy implements XSRFStrategy {
constructor(_cookieName?: string, _headerName?: string);
configureRequest(req: Request): void;
}
/** @experimental */
export declare class Headers {
constructor(headers?: Headers | {
[name: string]: any;
} | null);
append(name: string, value: string): void;
delete(name: string): void;
entries(): void;
forEach(fn: (values: string[], name: string | undefined, headers: Map<string, string[]>) => void): void;
get(name: string): string | null;
getAll(name: string): string[] | null;
has(name: string): boolean;
keys(): string[];
set(name: string, value: string | string[]): void;
toJSON(): {
[name: string]: any;
};
values(): string[][];
static fromResponseHeaderString(headersString: string): Headers;
}
/** @experimental */
export declare class Http {
protected _backend: ConnectionBackend;
protected _defaultOptions: RequestOptions;
constructor(_backend: ConnectionBackend, _defaultOptions: RequestOptions);
delete(url: string, options?: RequestOptionsArgs): Observable<Response>;
get(url: string, options?: RequestOptionsArgs): Observable<Response>;
head(url: string, options?: RequestOptionsArgs): Observable<Response>;
options(url: string, options?: RequestOptionsArgs): Observable<Response>;
patch(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
post(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
put(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response>;
}
/** @experimental */
export declare class HttpModule {
}
/** @experimental */
export declare class Jsonp extends Http {
constructor(backend: ConnectionBackend, defaultOptions: RequestOptions);
request(url: string | Request, options?: RequestOptionsArgs): Observable<Response>;
}
/** @experimental */
export declare abstract class JSONPBackend extends ConnectionBackend {
}
/** @experimental */
export declare abstract class JSONPConnection implements Connection {
readyState: ReadyState;
request: Request;
response: Observable<Response>;
abstract finished(data?: any): void;
}
/** @experimental */
export declare class JsonpModule {
}
/** @experimental */
export declare class QueryEncoder {
encodeKey(k: string): string;
encodeValue(v: string): string;
}
/** @experimental */
export declare enum ReadyState {
Unsent = 0,
Open = 1,
HeadersReceived = 2,
Loading = 3,
Done = 4,
Cancelled = 5,
}
/** @experimental */
export declare class Request extends Body {
headers: Headers;
method: RequestMethod;
responseType: ResponseContentType;
url: string;
withCredentials: boolean;
constructor(requestOptions: RequestArgs);
detectContentType(): ContentType;
detectContentTypeFromBody(): ContentType;
getBody(): any;
}
/** @experimental */
export declare enum RequestMethod {
Get = 0,
Post = 1,
Put = 2,
Delete = 3,
Options = 4,
Head = 5,
Patch = 6,
}
/** @experimental */
export declare class RequestOptions {
body: any;
headers: Headers | null;
method: RequestMethod | string | null;
params: URLSearchParams;
responseType: ResponseContentType | null;
/** @deprecated */ search: URLSearchParams;
url: string | null;
withCredentials: boolean | null;
constructor(opts?: RequestOptionsArgs);
merge(options?: RequestOptionsArgs): RequestOptions;
}
/** @experimental */
export interface RequestOptionsArgs {
body?: any;
headers?: Headers | null;
method?: string | RequestMethod | null;
params?: string | URLSearchParams | {
[key: string]: any | any[];
} | null;
responseType?: ResponseContentType | null;
/** @deprecated */ search?: string | URLSearchParams | {
[key: string]: any | any[];
} | null;
url?: string | null;
withCredentials?: boolean | null;
}
/** @experimental */
export declare class Response extends Body {
bytesLoaded: number;
headers: Headers | null;
ok: boolean;
status: number;
statusText: string | null;
totalBytes: number;
type: ResponseType;
url: string;
constructor(responseOptions: ResponseOptions);
toString(): string;
}
/** @experimental */
export declare enum ResponseContentType {
Text = 0,
Json = 1,
ArrayBuffer = 2,
Blob = 3,
}
/** @experimental */
export declare class ResponseOptions {
body: string | Object | ArrayBuffer | Blob | null;
headers: Headers | null;
status: number | null;
url: string | null;
constructor(opts?: ResponseOptionsArgs);
merge(options?: ResponseOptionsArgs): ResponseOptions;
}
/** @experimental */
export interface ResponseOptionsArgs {
body?: string | Object | FormData | ArrayBuffer | Blob | null;
headers?: Headers | null;
status?: number | null;
statusText?: string | null;
type?: ResponseType | null;
url?: string | null;
}
/** @experimental */
export declare enum ResponseType {
Basic = 0,
Cors = 1,
Default = 2,
Error = 3,
Opaque = 4,
}
/** @experimental */
export declare class URLSearchParams {
paramsMap: Map<string, string[]>;
rawParams: string;
constructor(rawParams?: string, queryEncoder?: QueryEncoder);
append(param: string, val: string): void;
appendAll(searchParams: URLSearchParams): void;
clone(): URLSearchParams;
delete(param: string): void;
get(param: string): string | null;
getAll(param: string): string[];
has(param: string): boolean;
replaceAll(searchParams: URLSearchParams): void;
set(param: string, val: string): void;
setAll(searchParams: URLSearchParams): void;
toString(): string;
}
/** @stable */
export declare const VERSION: Version;
/** @experimental */
export declare class XHRBackend implements ConnectionBackend {
constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy);
createConnection(request: Request): XHRConnection;
}
/** @experimental */
export declare class XHRConnection implements Connection {
readyState: ReadyState;
request: Request;
response: Observable<Response>;
constructor(req: Request, browserXHR: BrowserXhr, baseResponseOptions?: ResponseOptions);
setDetectedContentType(req: any, _xhr: any): void;
}
/** @experimental */
export declare abstract class XSRFStrategy {
abstract configureRequest(req: Request): void;
}