diff --git a/modules/angular2/http.ts b/modules/angular2/http.ts index 6bb008b357..1703c54888 100644 --- a/modules/angular2/http.ts +++ b/modules/angular2/http.ts @@ -34,14 +34,7 @@ export {Http, Jsonp} from './src/http/http'; export {Headers} from './src/http/headers'; -export { - ResponseTypes, - ReadyStates, - RequestMethods, - RequestCredentialsOpts, - RequestCacheOpts, - RequestModesOpts -} from './src/http/enums'; +export {ResponseTypes, ReadyStates, RequestMethods} from './src/http/enums'; export {URLSearchParams} from './src/http/url_search_params'; /** diff --git a/modules/angular2/src/http/base_request_options.ts b/modules/angular2/src/http/base_request_options.ts index a20ee93967..eac87c0b53 100644 --- a/modules/angular2/src/http/base_request_options.ts +++ b/modules/angular2/src/http/base_request_options.ts @@ -1,6 +1,6 @@ import {CONST_EXPR, CONST, isPresent, isString} from 'angular2/src/core/facade/lang'; import {Headers} from './headers'; -import {RequestModesOpts, RequestMethods, RequestCacheOpts, RequestCredentialsOpts} from './enums'; +import {RequestMethods} from './enums'; import {RequestOptionsArgs} from './interfaces'; import {Injectable} from 'angular2/src/core/di'; import {URLSearchParams} from './url_search_params'; @@ -30,19 +30,12 @@ export class RequestOptions { */ // TODO: support FormData, Blob, URLSearchParams body: string; - mode: RequestModesOpts; - credentials: RequestCredentialsOpts; - cache: RequestCacheOpts; url: string; search: URLSearchParams; - constructor({method, headers, body, mode, credentials, cache, url, search}: - RequestOptionsArgs = {}) { + constructor({method, headers, body, url, search}: RequestOptionsArgs = {}) { this.method = isPresent(method) ? method : null; this.headers = isPresent(headers) ? headers : null; this.body = isPresent(body) ? body : null; - this.mode = isPresent(mode) ? mode : null; - this.credentials = isPresent(credentials) ? credentials : null; - this.cache = isPresent(cache) ? cache : null; this.url = isPresent(url) ? url : null; this.search = isPresent(search) ? (isString(search) ? new URLSearchParams((search)) : (search)) : @@ -58,10 +51,6 @@ export class RequestOptions { method: isPresent(options) && isPresent(options.method) ? options.method : this.method, headers: isPresent(options) && isPresent(options.headers) ? options.headers : this.headers, body: isPresent(options) && isPresent(options.body) ? options.body : this.body, - mode: isPresent(options) && isPresent(options.mode) ? options.mode : this.mode, - credentials: isPresent(options) && isPresent(options.credentials) ? options.credentials : - this.credentials, - cache: isPresent(options) && isPresent(options.cache) ? options.cache : this.cache, url: isPresent(options) && isPresent(options.url) ? options.url : this.url, search: isPresent(options) && isPresent(options.search) ? (isString(options.search) ? new URLSearchParams((options.search)) : @@ -91,7 +80,5 @@ export class RequestOptions { */ @Injectable() export class BaseRequestOptions extends RequestOptions { - constructor() { - super({method: RequestMethods.Get, headers: new Headers(), mode: RequestModesOpts.Cors}); - } + constructor() { super({method: RequestMethods.Get, headers: new Headers()}); } } diff --git a/modules/angular2/src/http/enums.ts b/modules/angular2/src/http/enums.ts index b6ef3da811..322131e63c 100644 --- a/modules/angular2/src/http/enums.ts +++ b/modules/angular2/src/http/enums.ts @@ -1,38 +1,5 @@ import {StringMap, StringMapWrapper} from 'angular2/src/core/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, - Reload, - NoCache, - ForceCache, - 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. */ diff --git a/modules/angular2/src/http/interfaces.ts b/modules/angular2/src/http/interfaces.ts index 8f07564ffc..aa3173d1da 100644 --- a/modules/angular2/src/http/interfaces.ts +++ b/modules/angular2/src/http/interfaces.ts @@ -1,11 +1,4 @@ -import { - ReadyStates, - RequestModesOpts, - RequestMethods, - RequestCacheOpts, - RequestCredentialsOpts, - ResponseTypes -} from './enums'; +import {ReadyStates, RequestMethods, ResponseTypes} from './enums'; import {Headers} from './headers'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; import {EventEmitter} from 'angular2/src/core/facade/async'; @@ -49,9 +42,6 @@ export interface RequestOptionsArgs { headers?: Headers; // TODO: Support Blob, ArrayBuffer, JSON, URLSearchParams, FormData body?: string; - mode?: RequestModesOpts; - credentials?: RequestCredentialsOpts; - cache?: RequestCacheOpts; } /** diff --git a/modules/angular2/src/http/static_request.ts b/modules/angular2/src/http/static_request.ts index 4d182b3ced..19595221ad 100644 --- a/modules/angular2/src/http/static_request.ts +++ b/modules/angular2/src/http/static_request.ts @@ -1,4 +1,4 @@ -import {RequestMethods, RequestModesOpts, RequestCredentialsOpts, RequestCacheOpts} from './enums'; +import {RequestMethods} from './enums'; import {RequestOptions} from './base_request_options'; import {Headers} from './headers'; import { @@ -26,8 +26,6 @@ export class Request { * Defaults to GET. */ method: RequestMethods; - mode: RequestModesOpts; - credentials: RequestCredentialsOpts; /** * Headers object based on the `Headers` class in the [Fetch * Spec](https://fetch.spec.whatwg.org/#headers-class). {@link Headers} class reference. @@ -37,7 +35,6 @@ export class Request { url: string; // TODO: support URLSearchParams | FormData | Blob | ArrayBuffer private _body: string; - cache: RequestCacheOpts; constructor(requestOptions: RequestOptions) { // TODO: assert that url is present let url = requestOptions.url; @@ -56,12 +53,9 @@ export class Request { this._body = requestOptions.body; this.method = requestOptions.method; // TODO(jeffbcross): implement behavior - this.mode = requestOptions.mode; // Defaults to 'omit', consistent with browser // TODO(jeffbcross): implement behavior - this.credentials = requestOptions.credentials; this.headers = new Headers(requestOptions.headers); - this.cache = requestOptions.cache; } diff --git a/modules/angular2/test/http/base_request_options_spec.ts b/modules/angular2/test/http/base_request_options_spec.ts index 13144695bb..9ec405a98b 100644 --- a/modules/angular2/test/http/base_request_options_spec.ts +++ b/modules/angular2/test/http/base_request_options_spec.ts @@ -10,7 +10,7 @@ import { xit } from 'angular2/test_lib'; import {BaseRequestOptions, RequestOptions} from 'angular2/src/http/base_request_options'; -import {RequestMethods, RequestModesOpts} from 'angular2/src/http/enums'; +import {RequestMethods} from 'angular2/src/http/enums'; export function main() { describe('BaseRequestOptions', () => { @@ -24,9 +24,7 @@ export function main() { it('should retain previously merged values when merging again', () => { var options1 = new BaseRequestOptions(); var options2 = options1.merge(new RequestOptions({method: RequestMethods.Delete})); - var options3 = options2.merge(new RequestOptions({mode: RequestModesOpts.NoCors})); - expect(options3.mode).toBe(RequestModesOpts.NoCors); - expect(options3.method).toBe(RequestMethods.Delete); + expect(options2.method).toBe(RequestMethods.Delete); }); }); }