Permalink
Browse files

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

Add options method to the Http object, which could be useful when using self-describing RESTful APIs.

This closes #10500, closes #7918
  • Loading branch information...
cassand authored and alxhub committed Aug 8, 2016
1 parent 46bbcef commit 0bd97ecda260d522f2e786c7e7a117314b7d2f98
@@ -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)));
}
}
@@ -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) => {
@@ -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>;

0 comments on commit 0bd97ec

Please sign in to comment.