Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(http): add options method to Http #10540

Merged
merged 1 commit into from Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions modules/@angular/http/src/http.ts
Expand Up @@ -186,6 +186,15 @@ export class Http {
this._backend,
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Head, url)));
}

/**
* Performs a request with `options` http method.
*/
options(url: string, options?: RequestOptionsArgs): Observable<Response> {
return httpRequest(
this._backend,
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Options, url)));
}
}


Expand Down
13 changes: 13 additions & 0 deletions modules/@angular/http/test/http_spec.ts
Expand Up @@ -310,6 +310,19 @@ export function main() {
});


describe('.options()', () => {
it('should perform an options request for given url',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
backend.connections.subscribe((c: MockConnection) => {
expect(c.request.method).toBe(RequestMethod.Options);
backend.resolveAllConnections();
async.done();
});
http.options(url).subscribe((res: Response) => {});
}));
});


describe('searchParams', () => {
it('should append search params to url',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
Expand Down
1 change: 1 addition & 0 deletions tools/public_api_guard/http/index.d.ts
Expand Up @@ -64,6 +64,7 @@ export declare class Http {
delete(url: string, options?: RequestOptionsArgs): Observable<Response>;
get(url: string, options?: RequestOptionsArgs): Observable<Response>;
head(url: string, options?: RequestOptionsArgs): Observable<Response>;
options(url: string, options?: RequestOptionsArgs): Observable<Response>;
patch(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
post(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
put(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
Expand Down