refactor(http): remove default settings from RequestOptions
constructor
The BaseRequestOptions class is responsible for declaring default values, while the RequestOptions class is merely responsible for setting values based on values provided in the constructor.
This commit is contained in:
@ -1,11 +1,19 @@
|
||||
import {StringMap, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
/**
|
||||
* Acceptable origin modes to be associated with a {@link Request}, based on
|
||||
* [RequestMode](https://fetch.spec.whatwg.org/#requestmode) from the Fetch spec.
|
||||
*/
|
||||
export enum RequestModesOpts {
|
||||
Cors,
|
||||
NoCors,
|
||||
SameOrigin
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceptable cache option to be associated with a {@link Request}, based on
|
||||
* [RequestCache](https://fetch.spec.whatwg.org/#requestcache) from the Fetch spec.
|
||||
*/
|
||||
export enum RequestCacheOpts {
|
||||
Default,
|
||||
NoStore,
|
||||
@ -15,12 +23,19 @@ export enum RequestCacheOpts {
|
||||
OnlyIfCached
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceptable credentials option to be associated with a {@link Request}, based on
|
||||
* [RequestCredentials](https://fetch.spec.whatwg.org/#requestcredentials) from the Fetch spec.
|
||||
*/
|
||||
export enum RequestCredentialsOpts {
|
||||
Omit,
|
||||
SameOrigin,
|
||||
Include
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported http methods.
|
||||
*/
|
||||
export enum RequestMethods {
|
||||
GET,
|
||||
POST,
|
||||
@ -38,7 +53,11 @@ export class RequestMethodsMap {
|
||||
constructor() { this._methods = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD', 'PATCH']; }
|
||||
getMethod(method: int): string { return this._methods[method]; }
|
||||
}
|
||||
|
||||
/**
|
||||
* All possible states in which a connection can be, based on
|
||||
* [States](http://www.w3.org/TR/XMLHttpRequest/#states) from the `XMLHttpRequest` spec, but with an
|
||||
* additional "CANCELLED" state.
|
||||
*/
|
||||
export enum ReadyStates {
|
||||
UNSENT,
|
||||
OPEN,
|
||||
@ -48,6 +67,10 @@ export enum ReadyStates {
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
/**
|
||||
* Acceptable response types to be associated with a {@link Response}, based on
|
||||
* [ResponseType](https://fetch.spec.whatwg.org/#responsetype) from the Fetch spec.
|
||||
*/
|
||||
export enum ResponseTypes {
|
||||
Basic,
|
||||
Cors,
|
||||
|
Reference in New Issue
Block a user