From 042e697e4ca55ea6f0708561fca5790cc9d7f7f3 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Tue, 25 Aug 2015 10:27:59 +0200 Subject: [PATCH] chore(http): remove unused properties from Request This removes properties mentioned in #3339 Closes #3339 --- .../angular2/src/http/base_request_options.ts | 16 +++------------- modules/angular2/src/http/static_request.ts | 8 +------- .../test/http/base_request_options_spec.ts | 6 ++---- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/modules/angular2/src/http/base_request_options.ts b/modules/angular2/src/http/base_request_options.ts index 5547a43fcb00..a54a0aef0dbd 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/di'; import {URLSearchParams} from './url_search_params'; @@ -30,19 +30,13 @@ 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}: + 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 +52,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)) : @@ -92,6 +82,6 @@ export class RequestOptions { @Injectable() export class BaseRequestOptions extends RequestOptions { constructor() { - super({method: RequestMethods.Get, headers: new Headers(), mode: RequestModesOpts.Cors}); + super({method: RequestMethods.Get, headers: new Headers()}); } } diff --git a/modules/angular2/src/http/static_request.ts b/modules/angular2/src/http/static_request.ts index 4b2c34b9eef0..0eb3019f2beb 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 13144695bb58..9ec405a98bc8 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); }); }); }