X Tutup
Skip to content

Commit 5a3ce87

Browse files
0x-r4bbitjeffbcross
authored andcommitted
chore(http): remove unused properties from Request
This removes properties mentioned in angular#3339 Closes angular#3339 Closes angular#3823
1 parent 2acc1ad commit 5a3ce87

File tree

6 files changed

+8
-79
lines changed

6 files changed

+8
-79
lines changed

modules/angular2/http.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@ export {Http, Jsonp} from './src/http/http';
3434

3535
export {Headers} from './src/http/headers';
3636

37-
export {
38-
ResponseTypes,
39-
ReadyStates,
40-
RequestMethods,
41-
RequestCredentialsOpts,
42-
RequestCacheOpts,
43-
RequestModesOpts
44-
} from './src/http/enums';
37+
export {ResponseTypes, ReadyStates, RequestMethods} from './src/http/enums';
4538
export {URLSearchParams} from './src/http/url_search_params';
4639

4740
/**

modules/angular2/src/http/base_request_options.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {CONST_EXPR, CONST, isPresent, isString} from 'angular2/src/core/facade/lang';
22
import {Headers} from './headers';
3-
import {RequestModesOpts, RequestMethods, RequestCacheOpts, RequestCredentialsOpts} from './enums';
3+
import {RequestMethods} from './enums';
44
import {RequestOptionsArgs} from './interfaces';
55
import {Injectable} from 'angular2/src/core/di';
66
import {URLSearchParams} from './url_search_params';
@@ -30,19 +30,12 @@ export class RequestOptions {
3030
*/
3131
// TODO: support FormData, Blob, URLSearchParams
3232
body: string;
33-
mode: RequestModesOpts;
34-
credentials: RequestCredentialsOpts;
35-
cache: RequestCacheOpts;
3633
url: string;
3734
search: URLSearchParams;
38-
constructor({method, headers, body, mode, credentials, cache, url, search}:
39-
RequestOptionsArgs = {}) {
35+
constructor({method, headers, body, url, search}: RequestOptionsArgs = {}) {
4036
this.method = isPresent(method) ? method : null;
4137
this.headers = isPresent(headers) ? headers : null;
4238
this.body = isPresent(body) ? body : null;
43-
this.mode = isPresent(mode) ? mode : null;
44-
this.credentials = isPresent(credentials) ? credentials : null;
45-
this.cache = isPresent(cache) ? cache : null;
4639
this.url = isPresent(url) ? url : null;
4740
this.search = isPresent(search) ? (isString(search) ? new URLSearchParams(<string>(search)) :
4841
<URLSearchParams>(search)) :
@@ -58,10 +51,6 @@ export class RequestOptions {
5851
method: isPresent(options) && isPresent(options.method) ? options.method : this.method,
5952
headers: isPresent(options) && isPresent(options.headers) ? options.headers : this.headers,
6053
body: isPresent(options) && isPresent(options.body) ? options.body : this.body,
61-
mode: isPresent(options) && isPresent(options.mode) ? options.mode : this.mode,
62-
credentials: isPresent(options) && isPresent(options.credentials) ? options.credentials :
63-
this.credentials,
64-
cache: isPresent(options) && isPresent(options.cache) ? options.cache : this.cache,
6554
url: isPresent(options) && isPresent(options.url) ? options.url : this.url,
6655
search: isPresent(options) && isPresent(options.search) ?
6756
(isString(options.search) ? new URLSearchParams(<string>(options.search)) :
@@ -91,7 +80,5 @@ export class RequestOptions {
9180
*/
9281
@Injectable()
9382
export class BaseRequestOptions extends RequestOptions {
94-
constructor() {
95-
super({method: RequestMethods.Get, headers: new Headers(), mode: RequestModesOpts.Cors});
96-
}
83+
constructor() { super({method: RequestMethods.Get, headers: new Headers()}); }
9784
}

modules/angular2/src/http/enums.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,5 @@
11
import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection';
22

3-
/**
4-
* Acceptable origin modes to be associated with a {@link Request}, based on
5-
* [RequestMode](https://fetch.spec.whatwg.org/#requestmode) from the Fetch spec.
6-
*/
7-
export enum RequestModesOpts {
8-
Cors,
9-
NoCors,
10-
SameOrigin
11-
}
12-
13-
/**
14-
* Acceptable cache option to be associated with a {@link Request}, based on
15-
* [RequestCache](https://fetch.spec.whatwg.org/#requestcache) from the Fetch spec.
16-
*/
17-
export enum RequestCacheOpts {
18-
Default,
19-
NoStore,
20-
Reload,
21-
NoCache,
22-
ForceCache,
23-
OnlyIfCached
24-
}
25-
26-
/**
27-
* Acceptable credentials option to be associated with a {@link Request}, based on
28-
* [RequestCredentials](https://fetch.spec.whatwg.org/#requestcredentials) from the Fetch spec.
29-
*/
30-
export enum RequestCredentialsOpts {
31-
Omit,
32-
SameOrigin,
33-
Include
34-
}
35-
363
/**
374
* Supported http methods.
385
*/

modules/angular2/src/http/interfaces.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
ReadyStates,
3-
RequestModesOpts,
4-
RequestMethods,
5-
RequestCacheOpts,
6-
RequestCredentialsOpts,
7-
ResponseTypes
8-
} from './enums';
1+
import {ReadyStates, RequestMethods, ResponseTypes} from './enums';
92
import {Headers} from './headers';
103
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
114
import {EventEmitter} from 'angular2/src/core/facade/async';
@@ -49,9 +42,6 @@ export interface RequestOptionsArgs {
4942
headers?: Headers;
5043
// TODO: Support Blob, ArrayBuffer, JSON, URLSearchParams, FormData
5144
body?: string;
52-
mode?: RequestModesOpts;
53-
credentials?: RequestCredentialsOpts;
54-
cache?: RequestCacheOpts;
5545
}
5646

5747
/**

modules/angular2/src/http/static_request.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {RequestMethods, RequestModesOpts, RequestCredentialsOpts, RequestCacheOpts} from './enums';
1+
import {RequestMethods} from './enums';
22
import {RequestOptions} from './base_request_options';
33
import {Headers} from './headers';
44
import {
@@ -26,8 +26,6 @@ export class Request {
2626
* Defaults to GET.
2727
*/
2828
method: RequestMethods;
29-
mode: RequestModesOpts;
30-
credentials: RequestCredentialsOpts;
3129
/**
3230
* Headers object based on the `Headers` class in the [Fetch
3331
* Spec](https://fetch.spec.whatwg.org/#headers-class). {@link Headers} class reference.
@@ -37,7 +35,6 @@ export class Request {
3735
url: string;
3836
// TODO: support URLSearchParams | FormData | Blob | ArrayBuffer
3937
private _body: string;
40-
cache: RequestCacheOpts;
4138
constructor(requestOptions: RequestOptions) {
4239
// TODO: assert that url is present
4340
let url = requestOptions.url;
@@ -56,12 +53,9 @@ export class Request {
5653
this._body = requestOptions.body;
5754
this.method = requestOptions.method;
5855
// TODO(jeffbcross): implement behavior
59-
this.mode = requestOptions.mode;
6056
// Defaults to 'omit', consistent with browser
6157
// TODO(jeffbcross): implement behavior
62-
this.credentials = requestOptions.credentials;
6358
this.headers = new Headers(requestOptions.headers);
64-
this.cache = requestOptions.cache;
6559
}
6660

6761

modules/angular2/test/http/base_request_options_spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
xit
1111
} from 'angular2/test_lib';
1212
import {BaseRequestOptions, RequestOptions} from 'angular2/src/http/base_request_options';
13-
import {RequestMethods, RequestModesOpts} from 'angular2/src/http/enums';
13+
import {RequestMethods} from 'angular2/src/http/enums';
1414

1515
export function main() {
1616
describe('BaseRequestOptions', () => {
@@ -24,9 +24,7 @@ export function main() {
2424
it('should retain previously merged values when merging again', () => {
2525
var options1 = new BaseRequestOptions();
2626
var options2 = options1.merge(new RequestOptions({method: RequestMethods.Delete}));
27-
var options3 = options2.merge(new RequestOptions({mode: RequestModesOpts.NoCors}));
28-
expect(options3.mode).toBe(RequestModesOpts.NoCors);
29-
expect(options3.method).toBe(RequestMethods.Delete);
27+
expect(options2.method).toBe(RequestMethods.Delete);
3028
});
3129
});
3230
}

0 commit comments

Comments
 (0)
X Tutup