From 18559897a0852dd8a8286cd209d8172f08bb604a Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Wed, 12 Jul 2017 17:00:23 -0700 Subject: [PATCH] fix(common): document HttpClient, fixing a few other issues --- packages/common/http/src/backend.ts | 16 + packages/common/http/src/client.ts | 778 +++++++++++++++++++- packages/common/http/testing/src/api.ts | 70 +- packages/common/http/testing/src/backend.ts | 4 +- packages/common/http/testing/src/request.ts | 14 +- tools/public_api_guard/common/http.d.ts | 606 +++++++-------- 6 files changed, 1178 insertions(+), 310 deletions(-) diff --git a/packages/common/http/src/backend.ts b/packages/common/http/src/backend.ts index f7c9afd1f7..78342d9cef 100644 --- a/packages/common/http/src/backend.ts +++ b/packages/common/http/src/backend.ts @@ -11,6 +11,15 @@ import {HttpRequest} from './request'; import {HttpEvent} from './response'; /** + * Transforms an `HttpRequest` into a stream of `HttpEvent`s, one of which will likely be a + * `HttpResponse`. + * + * `HttpHandler` is injectable. When injected, the handler instance dispatches requests to the + * first interceptor in the chain, which dispatches to the second, etc, eventually reaching the + * `HttpBackend`. + * + * In an `HttpInterceptor`, the `HttpHandler` parameter is the next interceptor in the chain. + * * @experimental */ export abstract class HttpHandler { @@ -18,6 +27,13 @@ export abstract class HttpHandler { } /** + * A final `HttpHandler` which will dispatch the request via browser HTTP APIs to a backend. + * + * Interceptors sit between the `HttpClient` interface and the `HttpBackend`. + * + * When injected, `HttpBackend` dispatches requests directly to the backend, without going + * through the interceptor chain. + * * @experimental */ export abstract class HttpBackend implements HttpHandler { diff --git a/packages/common/http/src/client.ts b/packages/common/http/src/client.ts index 92e0334433..d77181e492 100644 --- a/packages/common/http/src/client.ts +++ b/packages/common/http/src/client.ts @@ -49,7 +49,11 @@ function addBody( export type HttpObserve = 'body' | 'events' | 'response'; /** - * The main API for making outgoing HTTP requests. + * Perform HTTP requests. + * + * `HttpClient` is available as an injectable class, with methods to perform HTTP requests. + * Each request method has multiple signatures, and the return type varies according to which + * signature is called (mainly the values of `observe` and `responseType`). * * @experimental */ @@ -57,7 +61,16 @@ export type HttpObserve = 'body' | 'events' | 'response'; export class HttpClient { constructor(private handler: HttpHandler) {} + /** + * Send the given `HttpRequest` and return a stream of `HttpEvents`. + */ request(req: HttpRequest): Observable>; + + /** + * Construct a request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, @@ -65,6 +78,12 @@ export class HttpClient { params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable; + + /** + * Construct a request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, @@ -72,6 +91,12 @@ export class HttpClient { params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, @@ -79,6 +104,12 @@ export class HttpClient { params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct a request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, @@ -86,46 +117,116 @@ export class HttpClient { observe: 'events', responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as an `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ + request(method: string, url: string, options: { + body?: any, + headers?: HttpHeaders, + observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, + }): Observable>; + + /** + * Construct a request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `R`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ + request(method: string, url: string, options: { + body?: any, + headers?: HttpHeaders, + observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, + }): Observable>; + + /** + * Construct a request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `R`. + */ request(method: string, url: string, options: { body?: any, headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ request(method: string, url: string, options?: { body?: any, headers?: HttpHeaders, @@ -134,6 +235,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `R`. + */ request(method: string, url: string, options?: { body?: any, headers?: HttpHeaders, @@ -142,6 +249,13 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a request in a manner where response type and requested `Observable` are not known + * statically. + * + * @return an `Observable` of whatever was requested, typed to `any`. + */ request(method: string, url: string, options?: { body?: any, headers?: HttpHeaders, @@ -150,6 +264,7 @@ export class HttpClient { responseType?: 'arraybuffer'|'blob'|'json'|'text', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` for a particular HTTP request that, when subscribed, * fires the request through the chain of registered interceptors and on to the @@ -275,70 +390,154 @@ export class HttpClient { } } + /** + * Construct a DELETE request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ delete (url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable; + + + /** + * Construct a DELETE request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ delete (url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a DELETE request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ delete (url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct a DELETE request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as a `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. + */ delete(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ delete (url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `T`. + */ delete(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a DELETE request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as an `Object`. + */ delete (url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -346,6 +545,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a DELETE request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as type `T`. + */ delete(url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -353,9 +558,10 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause the configured - * DELETE request to be executed on the server. See {@link HttpClient#request} for + * DELETE request to be executed on the server. See the individual overloads for * details of `delete()`'s return type based on the provided options. */ delete (url: string, options: { @@ -368,70 +574,154 @@ export class HttpClient { return this.request('DELETE', url, options as any); } + + /** + * Construct a GET request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ get(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable; + + /** + * Construct a GET request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ get(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a GET request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ get(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct a GET request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as a `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `T`. + */ get(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a GET request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as an `Object`. + */ get(url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -439,6 +729,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a GET request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as type `T`. + */ get(url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -446,9 +742,10 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause the configured - * GET request to be executed on the server. See {@link HttpClient#request} for + * GET request to be executed on the server. See the individual overloads for * details of `get()`'s return type based on the provided options. */ get(url: string, options: { @@ -461,11 +758,23 @@ export class HttpClient { return this.request('GET', url, options as any); } + + /** + * Construct a HEAD request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ head(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, + + /** + * Construct a HEAD request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ }): Observable; head(url: string, options: { headers?: HttpHeaders, @@ -473,58 +782,130 @@ export class HttpClient { params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a HEAD request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ head(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct a GET request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as a `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `T`. + */ head(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a HEAD request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as an `Object`. + */ head(url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -532,6 +913,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a HEAD request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as type `T`. + */ head(url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -539,9 +926,10 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause the configured - * HEAD request to be executed on the server. See {@link HttpClient#request} for + * HEAD request to be executed on the server. See the individual overloads for * details of `head()`'s return type based on the provided options. */ head(url: string, options: { @@ -554,8 +942,20 @@ export class HttpClient { return this.request('HEAD', url, options as any); } - jsonp(url: string, callbackParam: string): Observable; + /** + * Construct a JSONP request for the given URL and name of the callback parameter. + * + * @return an `Observable` of the response object as an `Object` + */ + jsonp(url: string, callbackParam: string): Observable; + + /** + * Construct a JSONP request for the given URL and name of the callback parameter. + * + * @return an `Observable` of the response object as type `T`. + */ jsonp(url: string, callbackParam: string): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause a request * with the special method `JSONP` to be dispatched via the interceptor pipeline. @@ -572,70 +972,153 @@ export class HttpClient { }); } + /** + * Make an OPTIONS request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ options(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable; + + /** + * Construct an OPTIONS request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ options(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a OPTIONS request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ options(url: string, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct an OPTIONS request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as a `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `T`. + */ options(url: string, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct an OPTIONS request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as an `Object`. + */ options(url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -643,6 +1126,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct an OPTIONS request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as type `T`. + */ options(url: string, options?: { headers?: HttpHeaders, observe?: 'body', @@ -650,9 +1139,10 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause the configured - * OPTIONS request to be executed on the server. See {@link HttpClient#request} for + * OPTIONS request to be executed on the server. See the individual overloads for * details of `options()`'s return type based on the provided options. */ options(url: string, options: { @@ -665,70 +1155,153 @@ export class HttpClient { return this.request('OPTIONS', url, options as any); } + /** + * Construct a PATCH request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable; + + /** + * Construct a PATCH request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a PATCH request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct a PATCH request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as a `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `T`. + */ patch(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PATCH request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as an `Object`. + */ patch(url: string, body: any|null, options?: { headers?: HttpHeaders, observe?: 'body', @@ -736,6 +1309,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a PATCH request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as type `T`. + */ patch(url: string, body: any|null, options?: { headers?: HttpHeaders, observe?: 'body', @@ -743,9 +1322,10 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause the configured - * PATCH request to be executed on the server. See {@link HttpClient#request} for + * PATCH request to be executed on the server. See the individual overloads for * details of `patch()`'s return type based on the provided options. */ patch(url: string, body: any|null, options: { @@ -758,70 +1338,153 @@ export class HttpClient { return this.request('PATCH', url, addBody(options, body)); } + /** + * Construct a POST request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable; + + /** + * Construct a POST request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a POST request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct a PATCH request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as a `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `T`. + */ post(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a POST request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as an `Object`. + */ post(url: string, body: any|null, options?: { headers?: HttpHeaders, observe?: 'body', @@ -829,6 +1492,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a POST request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as type `T`. + */ post(url: string, body: any|null, options?: { headers?: HttpHeaders, observe?: 'body', @@ -836,9 +1505,10 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause the configured - * POST request to be executed on the server. See {@link HttpClient#request} for + * POST request to be executed on the server. See the individual overloads for * details of `post()`'s return type based on the provided options. */ post(url: string, body: any|null, options: { @@ -851,70 +1521,153 @@ export class HttpClient { return this.request('POST', url, addBody(options, body)); } + /** + * Construct a PUT request which interprets the body as an `ArrayBuffer` and returns it. + * + * @return an `Observable` of the body as an `ArrayBuffer`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable; + + /** + * Construct a PUT request which interprets the body as a `Blob` and returns it. + * + * @return an `Observable` of the body as a `Blob`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable; + + /** + * Construct a PUT request which interprets the body as text and returns it. + * + * @return an `Observable` of the body as a `string`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe?: 'body', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable; + + /** + * Construct a PUT request which interprets the body as an `ArrayBuffer` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `ArrayBuffer`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as a `Blob` and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Blob`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as text and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `string`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `Object`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as JSON and returns the full event stream. + * + * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'events', responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as an `ArrayBuffer` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `ArrayBuffer`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'arraybuffer', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as a `Blob` and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Blob`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'blob', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as text and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `string`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType: 'text', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `Object`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as JSON and returns the full response. + * + * @return an `Observable` of the `HttpResponse` for the request, with a body type of `T`. + */ put(url: string, body: any|null, options: { headers?: HttpHeaders, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean, }): Observable>; + + /** + * Construct a PUT request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as an `Object`. + */ put(url: string, body: any|null, options?: { headers?: HttpHeaders, observe?: 'body', @@ -922,6 +1675,12 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + + /** + * Construct a PUT request which interprets the body as JSON and returns it. + * + * @return an `Observable` of the body as type `T`. + */ put(url: string, body: any|null, options?: { headers?: HttpHeaders, observe?: 'body', @@ -929,9 +1688,10 @@ export class HttpClient { responseType?: 'json', withCredentials?: boolean, }): Observable; + /** * Constructs an `Observable` which, when subscribed, will cause the configured - * POST request to be executed on the server. See {@link HttpClient#request} for + * POST request to be executed on the server. See the individual overloads for * details of `post()`'s return type based on the provided options. */ put(url: string, body: any|null, options: { diff --git a/packages/common/http/testing/src/api.ts b/packages/common/http/testing/src/api.ts index 81af8b224c..297ff36179 100644 --- a/packages/common/http/testing/src/api.ts +++ b/packages/common/http/testing/src/api.ts @@ -32,22 +32,86 @@ export abstract class HttpTestingController { */ abstract match(match: string|RequestMatch|((req: HttpRequest) => boolean)): TestRequest[]; - // Expect that exactly one request matches the given parameter. + /** + * Expect that a single request has been made which matches the given URL, and return its + * mock. + * + * If no such request has been made, or more than one such request has been made, fail with an + * error message including the given request description, if any. + */ abstract expectOne(url: string, description?: string): TestRequest; + + /** + * Expect that a single request has been made which matches the given parameters, and return + * its mock. + * + * If no such request has been made, or more than one such request has been made, fail with an + * error message including the given request description, if any. + */ abstract expectOne(params: RequestMatch, description?: string): TestRequest; + + /** + * Expect that a single request has been made which matches the given predicate function, and + * return its mock. + * + * If no such request has been made, or more than one such request has been made, fail with an + * error message including the given request description, if any. + */ abstract expectOne(matchFn: ((req: HttpRequest) => boolean), description?: string): TestRequest; + + /** + * Expect that a single request has been made which matches the given condition, and return + * its mock. + * + * If no such request has been made, or more than one such request has been made, fail with an + * error message including the given request description, if any. + */ abstract expectOne( match: string|RequestMatch|((req: HttpRequest) => boolean), description?: string): TestRequest; - // Assert that no requests match the given parameter. + /** + * Expect that no requests have been made which match the given URL. + * + * If a matching request has been made, fail with an error message including the given request + * description, if any. + */ abstract expectNone(url: string, description?: string): void; + + /** + * Expect that no requests have been made which match the given parameters. + * + * If a matching request has been made, fail with an error message including the given request + * description, if any. + */ abstract expectNone(params: RequestMatch, description?: string): void; + + /** + * Expect that no requests have been made which match the given predicate function. + * + * If a matching request has been made, fail with an error message including the given request + * description, if any. + */ abstract expectNone(matchFn: ((req: HttpRequest) => boolean), description?: string): void; + + /** + * Expect that no requests have been made which match the given condition. + * + * If a matching request has been made, fail with an error message including the given request + * description, if any. + */ abstract expectNone( match: string|RequestMatch|((req: HttpRequest) => boolean), description?: string): void; - // Validate that all requests which were issued were flushed. + /** + * Verify that no unmatched requests are outstanding. + * + * If any requests are outstanding, fail with an error message indicating which requests were not + * handled. + * + * If `ignoreCancelled` is not set (the default), `verify()` will also fail if cancelled requests + * were not explicitly matched. + */ abstract verify(opts?: {ignoreCancelled?: boolean}): void; } diff --git a/packages/common/http/testing/src/backend.ts b/packages/common/http/testing/src/backend.ts index 66cf5344e0..1cb5e2b125 100644 --- a/packages/common/http/testing/src/backend.ts +++ b/packages/common/http/testing/src/backend.ts @@ -38,10 +38,10 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl * Handle an incoming request by queueing it in the list of open requests. */ handle(req: HttpRequest): Observable> { - return new Observable((observer: Observer>) => { + return new Observable((observer: Observer) => { const testReq = new TestRequest(req, observer); this.open.push(testReq); - observer.next({type: HttpEventType.Sent}); + observer.next({ type: HttpEventType.Sent } as HttpEvent); return () => { testReq._cancelled = true; }; }); } diff --git a/packages/common/http/testing/src/request.ts b/packages/common/http/testing/src/request.ts index b6133afd6f..4bd68a1edd 100644 --- a/packages/common/http/testing/src/request.ts +++ b/packages/common/http/testing/src/request.ts @@ -30,7 +30,12 @@ export class TestRequest { constructor(public request: HttpRequest, private observer: Observer>) {} - + /** + * Resolve the request by returning a body plus additional HTTP information (such as response + * headers) if provided. + * + * Both successful and unsuccessful responses can be delivered via `flush()`. + */ flush(body: ArrayBuffer|Blob|string|number|Object|(string|number|Object|null)[]|null, opts: { headers?: HttpHeaders | {[name: string]: string | string[]}, status?: number, @@ -65,6 +70,9 @@ export class TestRequest { } } + /** + * Resolve the request by returning an `ErrorEvent` (e.g. simulating a network failure). + */ error(error: ErrorEvent, opts: { headers?: HttpHeaders | {[name: string]: string | string[]}, status?: number, @@ -87,6 +95,10 @@ export class TestRequest { })); } + /** + * Deliver an arbitrary `HttpEvent` (such as a progress event) on the response stream for this + * request. + */ event(event: HttpEvent): void { if (this.cancelled) { throw new Error(`Cannot send events to a cancelled request.`); diff --git a/tools/public_api_guard/common/http.d.ts b/tools/public_api_guard/common/http.d.ts index 87bbb59265..812324f9e1 100644 --- a/tools/public_api_guard/common/http.d.ts +++ b/tools/public_api_guard/common/http.d.ts @@ -23,83 +23,6 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'text'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'blob'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'arraybuffer'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType: 'text'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType: 'blob'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType: 'arraybuffer'; - withCredentials?: boolean; - }): Observable>; - delete(url: string, options: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType: 'text'; - withCredentials?: boolean; - }): Observable; delete(url: string, options: { headers?: HttpHeaders; observe?: 'body'; @@ -114,41 +37,83 @@ export declare class HttpClient { responseType: 'blob'; withCredentials?: boolean; }): Observable; - get(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - get(url: string, options: { + delete(url: string, options: { headers?: HttpHeaders; observe?: 'body'; params?: HttpParams; responseType: 'text'; withCredentials?: boolean; }): Observable; - get(url: string, options: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType: 'blob'; - withCredentials?: boolean; - }): Observable; - get(url: string, options: { + delete(url: string, options: { headers?: HttpHeaders; observe: 'events'; params?: HttpParams; responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable>; - get(url: string, options: { + delete(url: string, options: { headers?: HttpHeaders; observe: 'events'; params?: HttpParams; responseType: 'blob'; withCredentials?: boolean; }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType: 'arraybuffer'; + withCredentials?: boolean; + }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType: 'blob'; + withCredentials?: boolean; + }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + delete(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; get(url: string, options: { headers?: HttpHeaders; observe: 'events'; @@ -156,55 +121,6 @@ export declare class HttpClient { responseType: 'text'; withCredentials?: boolean; }): Observable>; - get(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - get(url: string, options: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType: 'arraybuffer'; - withCredentials?: boolean; - }): Observable; - get(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'arraybuffer'; - withCredentials?: boolean; - }): Observable>; - get(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'blob'; - withCredentials?: boolean; - }): Observable>; - get(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'text'; - withCredentials?: boolean; - }): Observable>; - get(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - get(url: string, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; get(url: string, options?: { headers?: HttpHeaders; observe?: 'body'; @@ -212,6 +128,41 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable; + get(url: string, options: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType: 'arraybuffer'; + withCredentials?: boolean; + }): Observable; + get(url: string, options: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType: 'blob'; + withCredentials?: boolean; + }): Observable; + get(url: string, options: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable; + get(url: string, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType: 'arraybuffer'; + withCredentials?: boolean; + }): Observable>; + get(url: string, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType: 'blob'; + withCredentials?: boolean; + }): Observable>; get(url: string, options?: { headers?: HttpHeaders; observe?: 'body'; @@ -219,48 +170,83 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable; - head(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType: 'arraybuffer'; - withCredentials?: boolean; - }): Observable>; - head(url: string, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType: 'text'; - withCredentials?: boolean; - }): Observable>; - head(url: string, options: { + get(url: string, options: { headers?: HttpHeaders; observe: 'events'; params?: HttpParams; responseType?: 'json'; withCredentials?: boolean; }): Observable>; - head(url: string, options: { + get(url: string, options: { headers?: HttpHeaders; observe: 'events'; params?: HttpParams; responseType?: 'json'; withCredentials?: boolean; }): Observable>; - head(url: string, options: { + get(url: string, options: { headers?: HttpHeaders; observe: 'response'; params?: HttpParams; responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable>; - head(url: string, options: { + get(url: string, options: { headers?: HttpHeaders; observe: 'response'; params?: HttpParams; responseType: 'blob'; withCredentials?: boolean; }): Observable>; + get(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable>; + get(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + get(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + head(url: string, options?: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable; + head(url: string, options?: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable; + head(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + head(url: string, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; head(url: string, options: { headers?: HttpHeaders; observe: 'response'; @@ -272,37 +258,37 @@ export declare class HttpClient { headers?: HttpHeaders; observe: 'response'; params?: HttpParams; - responseType?: 'json'; + responseType: 'blob'; withCredentials?: boolean; - }): Observable>; - head(url: string, options: { + }): Observable>; + head(url: string, options: { headers?: HttpHeaders; observe: 'response'; params?: HttpParams; - responseType?: 'json'; + responseType: 'arraybuffer'; withCredentials?: boolean; - }): Observable>; - head(url: string, options?: { + }): Observable>; + head(url: string, options: { headers?: HttpHeaders; - observe?: 'body'; + observe: 'events'; params?: HttpParams; responseType?: 'json'; withCredentials?: boolean; - }): Observable; - head(url: string, options?: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable; + }): Observable>; head(url: string, options: { headers?: HttpHeaders; - observe?: 'body'; + observe: 'events'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + head(url: string, options: { + headers?: HttpHeaders; + observe: 'events'; params?: HttpParams; responseType: 'text'; withCredentials?: boolean; - }): Observable; + }): Observable>; head(url: string, options: { headers?: HttpHeaders; observe: 'events'; @@ -312,11 +298,18 @@ export declare class HttpClient { }): Observable>; head(url: string, options: { headers?: HttpHeaders; - observe?: 'body'; + observe: 'events'; params?: HttpParams; responseType: 'arraybuffer'; withCredentials?: boolean; - }): Observable; + }): Observable>; + head(url: string, options: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable; head(url: string, options: { headers?: HttpHeaders; observe?: 'body'; @@ -324,15 +317,22 @@ export declare class HttpClient { responseType: 'blob'; withCredentials?: boolean; }): Observable; - jsonp(url: string, callbackParam: string): Observable; - jsonp(url: string, callbackParam: string): Observable; - options(url: string, options: { + head(url: string, options: { headers?: HttpHeaders; - observe: 'response'; + observe?: 'body'; params?: HttpParams; responseType: 'arraybuffer'; withCredentials?: boolean; - }): Observable>; + }): Observable; + jsonp(url: string, callbackParam: string): Observable; + jsonp(url: string, callbackParam: string): Observable; + options(url: string, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; options(url: string, options: { headers?: HttpHeaders; observe?: 'body'; @@ -340,6 +340,13 @@ export declare class HttpClient { responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable; + options(url: string, options: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType: 'blob'; + withCredentials?: boolean; + }): Observable; options(url: string, options: { headers?: HttpHeaders; observe?: 'body'; @@ -368,13 +375,13 @@ export declare class HttpClient { responseType: 'text'; withCredentials?: boolean; }): Observable>; - options(url: string, options: { + options(url: string, options?: { headers?: HttpHeaders; - observe: 'events'; + observe?: 'body'; params?: HttpParams; responseType?: 'json'; withCredentials?: boolean; - }): Observable>; + }): Observable; options(url: string, options: { headers?: HttpHeaders; observe: 'events'; @@ -384,11 +391,11 @@ export declare class HttpClient { }): Observable>; options(url: string, options: { headers?: HttpHeaders; - observe?: 'body'; + observe: 'response'; params?: HttpParams; - responseType: 'blob'; + responseType: 'arraybuffer'; withCredentials?: boolean; - }): Observable; + }): Observable>; options(url: string, options: { headers?: HttpHeaders; observe: 'response'; @@ -424,20 +431,20 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable; - options(url: string, options?: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable; patch(url: string, body: any | null, options: { headers?: HttpHeaders; observe: 'events'; params?: HttpParams; - responseType?: 'json'; + responseType: 'blob'; withCredentials?: boolean; - }): Observable>; + }): Observable>; + patch(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable>; patch(url: string, body: any | null, options: { headers?: HttpHeaders; observe?: 'body'; @@ -466,69 +473,6 @@ export declare class HttpClient { responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType: 'blob'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType: 'text'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'events'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'arraybuffer'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'blob'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType: 'text'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe: 'response'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable>; - patch(url: string, body: any | null, options?: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable; patch(url: string, body: any | null, options?: { headers?: HttpHeaders; observe?: 'body'; @@ -536,13 +480,76 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable; - post(url: string, body: any | null, options: { + patch(url: string, body: any | null, options?: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable; + patch(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + patch(url: string, body: any | null, options: { headers?: HttpHeaders; observe: 'events'; params?: HttpParams; responseType?: 'json'; withCredentials?: boolean; }): Observable>; + patch(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType: 'arraybuffer'; + withCredentials?: boolean; + }): Observable>; + patch(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType: 'blob'; + withCredentials?: boolean; + }): Observable>; + patch(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable>; + patch(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + patch(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; + post(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable>; + post(url: string, body: any | null, options?: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable; post(url: string, body: any | null, options: { headers?: HttpHeaders; observe?: 'body'; @@ -550,6 +557,13 @@ export declare class HttpClient { responseType: 'arraybuffer'; withCredentials?: boolean; }): Observable; + post(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType: 'blob'; + withCredentials?: boolean; + }): Observable; post(url: string, body: any | null, options: { headers?: HttpHeaders; observe?: 'body'; @@ -571,13 +585,13 @@ export declare class HttpClient { responseType: 'blob'; withCredentials?: boolean; }): Observable>; - post(url: string, body: any | null, options: { + post(url: string, body: any | null, options?: { headers?: HttpHeaders; - observe: 'events'; + observe?: 'body'; params?: HttpParams; - responseType: 'text'; + responseType?: 'json'; withCredentials?: boolean; - }): Observable>; + }): Observable; post(url: string, body: any | null, options: { headers?: HttpHeaders; observe: 'events'; @@ -585,13 +599,13 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable>; - post(url: string, body: any | null, options: { + post(url: string, body: any | null, options: { headers?: HttpHeaders; - observe?: 'body'; + observe: 'events'; params?: HttpParams; - responseType: 'blob'; + responseType?: 'json'; withCredentials?: boolean; - }): Observable; + }): Observable>; post(url: string, body: any | null, options: { headers?: HttpHeaders; observe: 'response'; @@ -627,20 +641,6 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable>; - post(url: string, body: any | null, options?: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable; - post(url: string, body: any | null, options?: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType?: 'json'; - withCredentials?: boolean; - }): Observable; put(url: string, body: any | null, options?: { headers?: HttpHeaders; observe?: 'body'; @@ -689,13 +689,6 @@ export declare class HttpClient { responseType?: 'json'; withCredentials?: boolean; }): Observable>; - put(url: string, body: any | null, options: { - headers?: HttpHeaders; - observe?: 'body'; - params?: HttpParams; - responseType: 'arraybuffer'; - withCredentials?: boolean; - }): Observable; put(url: string, body: any | null, options: { headers?: HttpHeaders; observe: 'events'; @@ -738,6 +731,13 @@ export declare class HttpClient { responseType: 'blob'; withCredentials?: boolean; }): Observable; + put(url: string, body: any | null, options: { + headers?: HttpHeaders; + observe?: 'body'; + params?: HttpParams; + responseType: 'arraybuffer'; + withCredentials?: boolean; + }): Observable; put(url: string, body: any | null, options?: { headers?: HttpHeaders; observe?: 'body'; @@ -750,9 +750,9 @@ export declare class HttpClient { headers?: HttpHeaders; observe: 'events'; params?: HttpParams; - responseType: 'text'; + responseType?: 'json'; withCredentials?: boolean; - }): Observable>; + }): Observable>; request(method: string, url: string, options?: { body?: any; headers?: HttpHeaders; @@ -801,6 +801,14 @@ export declare class HttpClient { responseType: 'blob'; withCredentials?: boolean; }): Observable>; + request(method: string, url: string, options: { + body?: any; + headers?: HttpHeaders; + observe: 'events'; + params?: HttpParams; + responseType: 'text'; + withCredentials?: boolean; + }): Observable>; request(req: HttpRequest): Observable>; request(method: string, url: string, options: { body?: any; @@ -834,6 +842,14 @@ export declare class HttpClient { responseType: 'text'; withCredentials?: boolean; }): Observable>; + request(method: string, url: string, options: { + body?: any; + headers?: HttpHeaders; + observe: 'response'; + params?: HttpParams; + responseType?: 'json'; + withCredentials?: boolean; + }): Observable>; request(method: string, url: string, options: { body?: any; headers?: HttpHeaders;