2016-06-23 16:47:54 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @license
|
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2016-05-26 22:47:20 +00:00
|
|
|
|
import {ReadyState, RequestMethod, ResponseContentType, ResponseType} from './enums';
|
2015-04-29 06:07:55 +00:00
|
|
|
|
import {Headers} from './headers';
|
2015-06-19 19:14:12 +00:00
|
|
|
|
import {Request} from './static_request';
|
2015-09-25 10:23:05 +00:00
|
|
|
|
import {URLSearchParams} from './url_search_params';
|
2015-06-19 19:14:12 +00:00
|
|
|
|
|
2015-06-24 07:27:07 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Abstract class from which real backends are derived.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given
|
|
|
|
|
|
* {@link Request}.
|
2016-06-27 19:27:23 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @experimental
|
2015-06-24 07:27:07 +00:00
|
|
|
|
*/
|
2015-10-06 13:53:39 +00:00
|
|
|
|
export abstract class ConnectionBackend { abstract createConnection(request: any): Connection; }
|
2015-06-19 19:14:12 +00:00
|
|
|
|
|
2015-06-24 07:27:07 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Abstract class from which real connections are derived.
|
2016-06-27 19:27:23 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @experimental
|
2015-06-24 07:27:07 +00:00
|
|
|
|
*/
|
2015-09-25 21:48:17 +00:00
|
|
|
|
export abstract class Connection {
|
2015-12-03 21:44:14 +00:00
|
|
|
|
readyState: ReadyState;
|
2015-06-19 19:14:12 +00:00
|
|
|
|
request: Request;
|
2015-10-01 23:04:20 +00:00
|
|
|
|
response: any; // TODO: generic of <Response>;
|
2015-06-19 19:14:12 +00:00
|
|
|
|
}
|
2015-04-29 06:07:55 +00:00
|
|
|
|
|
2016-06-27 19:27:23 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @experimental
|
|
|
|
|
|
*/
|
2016-06-08 23:38:52 +00:00
|
|
|
|
export abstract class XSRFStrategy { abstract configureRequest(req: Request): void; }
|
2016-05-28 03:15:40 +00:00
|
|
|
|
|
2015-06-24 07:27:07 +00:00
|
|
|
|
/**
|
2015-10-10 16:37:29 +00:00
|
|
|
|
* Interface for options to construct a RequestOptions, based on
|
2015-06-24 07:27:07 +00:00
|
|
|
|
* [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
|
2016-06-27 19:27:23 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @experimental
|
2015-06-24 07:27:07 +00:00
|
|
|
|
*/
|
2015-10-10 16:37:29 +00:00
|
|
|
|
export interface RequestOptionsArgs {
|
2015-06-19 19:14:12 +00:00
|
|
|
|
url?: string;
|
2016-06-08 23:38:52 +00:00
|
|
|
|
method?: string|RequestMethod;
|
2016-12-09 23:38:29 +00:00
|
|
|
|
/** @deprecated from 4.0.0. Use params instead. */
|
|
|
|
|
|
search?: string|URLSearchParams|{[key: string]: any | any[]};
|
|
|
|
|
|
params?: string|URLSearchParams|{[key: string]: any | any[]};
|
2015-04-29 06:07:55 +00:00
|
|
|
|
headers?: Headers;
|
2016-02-26 11:25:55 +00:00
|
|
|
|
body?: any;
|
2016-02-24 21:57:35 +00:00
|
|
|
|
withCredentials?: boolean;
|
2016-05-26 22:47:20 +00:00
|
|
|
|
responseType?: ResponseContentType;
|
2015-04-29 06:07:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-10-10 16:37:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Required structure when constructing new Request();
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface RequestArgs extends RequestOptionsArgs { url: string; }
|
|
|
|
|
|
|
2015-06-24 07:27:07 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Interface for options to construct a Response, based on
|
|
|
|
|
|
* [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec.
|
2016-06-27 19:27:23 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @experimental
|
2015-06-24 07:27:07 +00:00
|
|
|
|
*/
|
2015-09-07 05:14:19 +00:00
|
|
|
|
export type ResponseOptionsArgs = {
|
2016-07-21 20:44:38 +00:00
|
|
|
|
body?: string | Object | FormData | ArrayBuffer | Blob; status?: number; statusText?: string;
|
2016-05-26 22:47:20 +00:00
|
|
|
|
headers?: Headers;
|
2015-12-03 21:44:14 +00:00
|
|
|
|
type?: ResponseType;
|
2015-04-29 06:07:55 +00:00
|
|
|
|
url?: string;
|
2016-08-31 01:07:40 +00:00
|
|
|
|
};
|