@angular/common
Version:
Angular - commonly needed directives and services
1,315 lines (1,310 loc) • 103 kB
TypeScript
/**
* @license Angular v22.0.0
* (c) 2010-2026 Google LLC. https://angular.dev/
* License: MIT
*/
import { Observable } from 'rxjs';
import * as i0 from '@angular/core';
import { EnvironmentInjector, InjectionToken, Provider, EnvironmentProviders, Injector, ValueEqualityFn, WritableResource, ResourceRef, Signal, ResourceParamsContext } from '@angular/core';
import { HttpRequest, HttpEvent, HttpRequestOptions, HttpHeaders, HttpParams, HttpResponse, HttpProgressEvent, HttpContext } from './_module-chunk.js';
export { HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpContextToken, HttpDownloadProgressEvent, HttpErrorResponse, HttpEventType, HttpHeaderResponse, HttpParameterCodec, HttpParamsOptions, HttpResponseBase, HttpSentEvent, HttpStatusCode, HttpUploadProgressEvent, HttpUrlEncodingCodec, HttpUserEvent } from './_module-chunk.js';
import { XhrFactory } from './_xhr-chunk.js';
/**
* 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.
*
* @publicApi
*/
declare abstract class HttpBackend implements HttpHandler {
abstract handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
static ɵfac: i0.ɵɵFactoryDeclaration<HttpBackend, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HttpBackend>;
}
declare class HttpInterceptorHandler implements HttpHandler {
private backend;
private injector;
private chain;
private readonly pendingTasks;
private readonly contributeToStability;
constructor(backend: HttpBackend, injector: EnvironmentInjector);
handle(initialRequest: HttpRequest<any>): Observable<HttpEvent<any>>;
static ɵfac: i0.ɵɵFactoryDeclaration<HttpInterceptorHandler, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HttpInterceptorHandler>;
}
/**
* 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.
*
* @publicApi
*/
declare abstract class HttpHandler {
abstract handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
static ɵfac: i0.ɵɵFactoryDeclaration<HttpHandler, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HttpHandler>;
}
/**
* Common options for HttpClient requests.
*
* @publicApi 22.0
*/
interface HttpClientCommonOptions extends Omit<HttpRequestOptions, 'headers' | 'params'> {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe?: 'body' | 'events' | 'response';
params?: HttpParams | {
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
};
}
/**
* Performs HTTP requests.
* This service is available as an injectable class, with methods to perform HTTP requests.
* Each request method has multiple signatures, and the return type varies based on
* the signature that is called (mainly the values of `observe` and `responseType`).
*
* Note that the `responseType` *options* value is a String that identifies the
* single data type of the response.
* A single overload version of the method handles each response type.
* The value of `responseType` cannot be a union, as the combined signature could imply.
*
* @usageNotes
*
* ### HTTP Request Example
*
* ```ts
* // GET heroes whose name contains search term
* searchHeroes(term: string): observable<Hero[]>{
*
* const params = new HttpParams({fromString: 'name=term'});
* return this.httpClient.request('GET', this.heroesUrl, {responseType:'json', params});
* }
* ```
*
* Alternatively, the parameter string can be used without invoking HttpParams
* by directly joining to the URL.
* ```ts
* this.httpClient.request('GET', this.heroesUrl + '?' + 'name=term', {responseType:'json'});
* ```
*
*
* ### JSONP Example
* ```ts
* requestJsonp(url, callback = 'callback') {
* return this.httpClient.jsonp(this.heroesURL, callback);
* }
* ```
*
* ### PATCH Example
* ```ts
* // PATCH one of the heroes' name
* patchHero (id: number, heroName: string): Observable<{}> {
* const url = `${this.heroesUrl}/${id}`; // PATCH api/heroes/42
* return this.httpClient.patch(url, {name: heroName}, httpOptions)
* .pipe(catchError(this.handleError('patchHero')));
* }
* ```
*
* @see [HTTP Guide](guide/http)
* @see [HTTP Request](api/common/http/HttpRequest)
*
* @publicApi
*/
declare class HttpClient {
private handler;
constructor(handler: HttpHandler);
/**
* Sends an `HttpRequest` and returns a stream of `HttpEvent`s.
*
* @return An `Observable` of the response, with the response body as a stream of `HttpEvent`s.
*/
request<R>(req: HttpRequest<any>): Observable<HttpEvent<R>>;
/**
* Constructs a request that interprets the body as an `ArrayBuffer` and returns the response in
* an `ArrayBuffer`.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
*
* @return An `Observable` of the response, with the response body as an `ArrayBuffer`.
*/
request(method: string, url: string, options: {
body?: any;
observe?: 'body';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<ArrayBuffer>;
/**
* Constructs a request that interprets the body as a blob and returns
* the response as a blob.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body of type `Blob`.
*/
request(method: string, url: string, options: {
body?: any;
observe?: 'body';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<Blob>;
/**
* Constructs a request that interprets the body as a text string and
* returns a string value.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body of type string.
*/
request(method: string, url: string, options: {
body?: any;
observe?: 'body';
responseType: 'text';
} & HttpClientCommonOptions): Observable<string>;
/**
* Constructs a request that interprets the body as an `ArrayBuffer` and returns the
* the full event stream.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body as an array of `HttpEvent`s for
* the request.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'events';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpEvent<ArrayBuffer>>;
/**
* Constructs a request that interprets the body as a `Blob` and returns
* the full event stream.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request,
* with the response body of type `Blob`.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'events';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpEvent<Blob>>;
/**
* Constructs a request which interprets the body as a text string and returns the full event
* stream.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request,
* with the response body of type string.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'events';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpEvent<string>>;
/**
* Constructs a request which interprets the body as a JavaScript object and returns the full
* event stream.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request,
* with the response body of type `Object`.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<any>>;
/**
* Constructs a request which interprets the body as a JavaScript object and returns the full
* event stream.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request,
* with the response body of type `R`.
*/
request<R>(method: string, url: string, options: {
body?: any;
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<R>>;
/**
* Constructs a request which interprets the body as an `ArrayBuffer`
* and returns the full `HttpResponse`.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with the response body as an `ArrayBuffer`.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'response';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpResponse<ArrayBuffer>>;
/**
* Constructs a request which interprets the body as a `Blob` and returns the full `HttpResponse`.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with the response body of type `Blob`.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'response';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpResponse<Blob>>;
/**
* Constructs a request which interprets the body as a text stream and returns the full
* `HttpResponse`.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the HTTP response, with the response body of type string.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'response';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpResponse<string>>;
/**
* Constructs a request which interprets the body as a JavaScript object and returns the full
* `HttpResponse`.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the full `HttpResponse`,
* with the response body of type `Object`.
*/
request(method: string, url: string, options: {
body?: any;
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<Object>>;
/**
* Constructs a request which interprets the body as a JavaScript object and returns
* the full `HttpResponse` with the response body in the requested type.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the full `HttpResponse`, with the response body of type `R`.
*/
request<R>(method: string, url: string, options: {
body?: any;
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<R>>;
/**
* Constructs a request which interprets the body as a JavaScript object and returns the full
* `HttpResponse` as a JavaScript object.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with the response body of type `Object`.
*/
request(method: string, url: string, options?: {
body?: any;
observe?: 'body';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<Object>;
/**
* Constructs a request which interprets the body as a JavaScript object
* with the response body of the requested type.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with the response body of type `R`.
*/
request<R>(method: string, url: string, options?: {
body?: any;
observe?: 'body';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<R>;
/**
* Constructs a request where response type and requested observable are not known statically.
*
* @param method The HTTP method.
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the requested response, with body of type `any`.
*/
request(method: string, url: string, options?: {
body?: any;
observe?: 'body' | 'events' | 'response';
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
} & HttpClientCommonOptions): Observable<any>;
/**
* Constructs a `DELETE` request that interprets the body as an `ArrayBuffer`
* and returns the response as an `ArrayBuffer`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response body as an `ArrayBuffer`.
*/
delete(url: string, options: {
observe?: 'body';
responseType: 'arraybuffer';
body?: any | null;
} & HttpClientCommonOptions): Observable<ArrayBuffer>;
/**
* Constructs a `DELETE` request that interprets the body as a `Blob` and returns
* the response as a `Blob`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response body as a `Blob`.
*/
delete(url: string, options: {
observe?: 'body';
responseType: 'blob';
body?: any | null;
} & HttpClientCommonOptions): Observable<Blob>;
/**
* Constructs a `DELETE` request that interprets the body as a text string and returns
* a string.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body of type string.
*/
delete(url: string, options: {
observe?: 'body';
responseType: 'text';
body?: any | null;
} & HttpClientCommonOptions): Observable<string>;
/**
* Constructs a `DELETE` request that interprets the body as an `ArrayBuffer`
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request,
* with response body as an `ArrayBuffer`.
*/
delete(url: string, options: {
observe: 'events';
responseType: 'arraybuffer';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpEvent<ArrayBuffer>>;
/**
* Constructs a `DELETE` request that interprets the body as a `Blob`
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all the `HttpEvent`s for the request, with the response body as a
* `Blob`.
*/
delete(url: string, options: {
observe: 'events';
responseType: 'blob';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpEvent<Blob>>;
/**
* Constructs a `DELETE` request that interprets the body as a text string
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request, with the response
* body of type string.
*/
delete(url: string, options: {
observe: 'events';
responseType: 'text';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpEvent<string>>;
/**
* Constructs a `DELETE` request that interprets the body as JSON
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request, with response body of
* type `Object`.
*/
delete(url: string, options: {
observe: 'events';
responseType?: 'json';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpEvent<Object>>;
/**
* Constructs a `DELETE`request that interprets the body as JSON
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all the `HttpEvent`s for the request, with a response
* body in the requested type.
*/
delete<T>(url: string, options: {
observe: 'events';
responseType?: 'json';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpEvent<T>>;
/**
* Constructs a `DELETE` request that interprets the body as an `ArrayBuffer` and returns
* the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the full `HttpResponse`, with the response body as an `ArrayBuffer`.
*/
delete(url: string, options: {
observe: 'response';
responseType: 'arraybuffer';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpResponse<ArrayBuffer>>;
/**
* Constructs a `DELETE` request that interprets the body as a `Blob` and returns the full
* `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with the response body of type `Blob`.
*/
delete(url: string, options: {
observe: 'response';
responseType: 'blob';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpResponse<Blob>>;
/**
* Constructs a `DELETE` request that interprets the body as a text stream and
* returns the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the full `HttpResponse`, with the response body of type string.
*/
delete(url: string, options: {
observe: 'response';
responseType: 'text';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpResponse<string>>;
/**
* Constructs a `DELETE` request the interprets the body as a JavaScript object and returns
* the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with the response body of type `Object`.
*
*/
delete(url: string, options: {
observe: 'response';
responseType?: 'json';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpResponse<Object>>;
/**
* Constructs a `DELETE` request that interprets the body as JSON
* and returns the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with the response body of the requested type.
*/
delete<T>(url: string, options: {
observe: 'response';
responseType?: 'json';
body?: any | null;
} & HttpClientCommonOptions): Observable<HttpResponse<T>>;
/**
* Constructs a `DELETE` request that interprets the body as JSON and
* returns the response body as an object parsed from JSON.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body of type `Object`.
*/
delete(url: string, options?: {
observe?: 'body';
responseType?: 'json';
body?: any | null;
} & HttpClientCommonOptions): Observable<Object>;
/**
* Constructs a DELETE request that interprets the body as JSON and returns
* the response in a given type.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with response body in the requested type.
*/
delete<T>(url: string, options?: {
observe?: 'body';
responseType?: 'json';
body?: any | null;
} & HttpClientCommonOptions): Observable<T>;
/**
* Constructs a `GET` request that interprets the body as an `ArrayBuffer` and returns the
* response in an `ArrayBuffer`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body as an `ArrayBuffer`.
*/
get(url: string, options: {
observe?: 'body';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<ArrayBuffer>;
/**
* Constructs a `GET` request that interprets the body as a `Blob`
* and returns the response as a `Blob`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body as a `Blob`.
*/
get(url: string, options: {
observe?: 'body';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<Blob>;
/**
* Constructs a `GET` request that interprets the body as a text string
* and returns the response as a string value.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body of type string.
*/
get(url: string, options: {
observe?: 'body';
responseType: 'text';
} & HttpClientCommonOptions): Observable<string>;
/**
* Constructs a `GET` request that interprets the body as an `ArrayBuffer` and returns
* the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of all `HttpEvent`s for the request, with the response
* body as an `ArrayBuffer`.
*/
get(url: string, options: {
observe: 'events';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpEvent<ArrayBuffer>>;
/**
* Constructs a `GET` request that interprets the body as a `Blob` and
* returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body as a `Blob`.
*/
get(url: string, options: {
observe: 'events';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpEvent<Blob>>;
/**
* Constructs a `GET` request that interprets the body as a text string and returns
* the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body of type string.
*/
get(url: string, options: {
observe: 'events';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpEvent<string>>;
/**
* Constructs a `GET` request that interprets the body as JSON
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body of type `Object`.
*/
get(url: string, options: {
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<Object>>;
/**
* Constructs a `GET` request that interprets the body as JSON and returns the full
* event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with a response body in the requested type.
*/
get<T>(url: string, options: {
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<T>>;
/**
* Constructs a `GET` request that interprets the body as an `ArrayBuffer` and
* returns the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse` for the request,
* with the response body as an `ArrayBuffer`.
*/
get(url: string, options: {
observe: 'response';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpResponse<ArrayBuffer>>;
/**
* Constructs a `GET` request that interprets the body as a `Blob` and
* returns the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse` for the request,
* with the response body as a `Blob`.
*/
get(url: string, options: {
observe: 'response';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpResponse<Blob>>;
/**
* Constructs a `GET` request that interprets the body as a text stream and
* returns the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse` for the request,
* with the response body of type string.
*/
get(url: string, options: {
observe: 'response';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpResponse<string>>;
/**
* Constructs a `GET` request that interprets the body as JSON and
* returns the full `HttpResponse`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the full `HttpResponse`,
* with the response body of type `Object`.
*/
get(url: string, options: {
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<Object>>;
/**
* Constructs a `GET` request that interprets the body as JSON and returns
* the full `HttpResponse` with the response body in the requested type.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the full `HttpResponse`, with the response body in the requested type.
*/
get<T>(url: string, options: {
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<T>>;
/**
* Constructs a `GET` request that interprets the body as JSON and
* returns the response body as an object parsed from JSON.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
*
* @return An `Observable` of the response body as a JavaScript object.
*/
get(url: string, options?: {
observe?: 'body';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<Object>;
/**
* Constructs a `GET` request that interprets the body as JSON and returns
* the response body in a given type.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the `HttpResponse`, with a response body in the requested type.
*/
get<T>(url: string, options?: {
observe?: 'body';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<T>;
/**
* Constructs a `HEAD` request that interprets the body as an `ArrayBuffer` and
* returns the response as an `ArrayBuffer`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An `Observable` of the response, with the response body as an `ArrayBuffer`.
*/
head(url: string, options: {
observe?: 'body';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<ArrayBuffer>;
/**
* Constructs a \`HEAD\` request that interprets the body as a \`Blob\` and returns
* the response as a \`Blob\`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the response, with the response body as a \`Blob\`.
*/
head(url: string, options: {
observe?: 'body';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<Blob>;
/**
* Constructs a \`HEAD\` request that interprets the body as a text string and returns the response
* as a string value.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the response, with the response body of type string.
*/
head(url: string, options: {
observe?: 'body';
responseType: 'text';
} & HttpClientCommonOptions): Observable<string>;
/**
* Constructs a \`HEAD\` request that interprets the body as an \`ArrayBuffer\`
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of all \`HttpEvent\`s for the request,
* with the response body as an \`ArrayBuffer\`.
*/
head(url: string, options: {
observe: 'events';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpEvent<ArrayBuffer>>;
/**
* Constructs a \`HEAD\` request that interprets the body as a \`Blob\` and
* returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of all \`HttpEvent\`s for the request,
* with the response body as a \`Blob\`.
*/
head(url: string, options: {
observe: 'events';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpEvent<Blob>>;
/**
* Constructs a \`HEAD\` request that interprets the body as a text string
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of all \`HttpEvent\`s for the request, with the response body of type
* string.
*/
head(url: string, options: {
observe: 'events';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpEvent<string>>;
/**
* Constructs a \`HEAD\` request that interprets the body as JSON
* and returns the full HTTP event stream.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of all \`HttpEvent\`s for the request, with a response body of
* type \`Object\`.
*/
head(url: string, options: {
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<Object>>;
/**
* Constructs a \`HEAD\` request that interprets the body as JSON and
* returns the full event stream.
*
* @return An \`Observable\` of all the \`HttpEvent\`s for the request,
* with a response body in the requested type.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*/
head<T>(url: string, options: {
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<T>>;
/**
* Constructs a \`HEAD\` request that interprets the body as an \`ArrayBuffer\`
* and returns the full HTTP response.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with the response body as an \`ArrayBuffer\`.
*/
head(url: string, options: {
observe: 'response';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpResponse<ArrayBuffer>>;
/**
* Constructs a \`HEAD\` request that interprets the body as a \`Blob\` and returns
* the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with the response body as a blob.
*/
head(url: string, options: {
observe: 'response';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpResponse<Blob>>;
/**
* Constructs a \`HEAD\` request that interprets the body as text stream
* and returns the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with the response body of type string.
*/
head(url: string, options: {
observe: 'response';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpResponse<string>>;
/**
* Constructs a \`HEAD\` request that interprets the body as JSON and
* returns the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with the response body of type \`Object\`.
*/
head(url: string, options: {
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<Object>>;
/**
* Constructs a \`HEAD\` request that interprets the body as JSON
* and returns the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with a response body of the requested type.
*/
head<T>(url: string, options: {
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<T>>;
/**
* Constructs a \`HEAD\` request that interprets the body as JSON and
* returns the response body as an object parsed from JSON.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the response, with the response body as an object parsed from JSON.
*/
head(url: string, options?: HttpClientCommonOptions): Observable<Object>;
/**
* Constructs a \`HEAD\` request that interprets the body as JSON and returns
* the response in a given type.
*
* @param url The endpoint URL.
* @param options The HTTP options to send with the request.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with a response body of the given type.
*/
head<T>(url: string, options?: HttpClientCommonOptions): Observable<T>;
/**
* Constructs a `JSONP` request for the given URL and name of the callback parameter.
*
* @param url The resource URL.
* @param callbackParam The callback function name.
*
* @return An `Observable` of the response object, with response body as an object.
*/
jsonp(url: string, callbackParam: string): Observable<Object>;
/**
* Constructs a `JSONP` request for the given URL and name of the callback parameter.
*
* @param url The resource URL.
* @param callbackParam The callback function name.
*
* You must install a suitable interceptor, such as one provided by `HttpClientJsonpModule`.
* If no such interceptor is reached,
* then the `JSONP` request can be rejected by the configured backend.
*
* @return An `Observable` of the response object, with response body in the requested type.
*/
jsonp<T>(url: string, callbackParam: string): Observable<T>;
/**
* Constructs an `OPTIONS` request that interprets the body as an
* `ArrayBuffer` and returns the response as an `ArrayBuffer`.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An `Observable` of the response, with the response body as an `ArrayBuffer`.
*/
options(url: string, options: {
observe?: 'body';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<ArrayBuffer>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as a \`Blob\` and returns
* the response as a \`Blob\`.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the response, with the response body as a \`Blob\`.
*/
options(url: string, options: {
observe?: 'body';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<Blob>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as a text string and
* returns a string value.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the response, with the response body of type string.
*/
options(url: string, options: {
observe?: 'body';
responseType: 'text';
} & HttpClientCommonOptions): Observable<string>;
/**
* Constructs an `OPTIONS` request that interprets the body as an `ArrayBuffer`
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An `Observable` of all `HttpEvent`s for the request,
* with the response body as an `ArrayBuffer`.
*/
options(url: string, options: {
observe: 'events';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpEvent<ArrayBuffer>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as a \`Blob\` and
* returns the full event stream.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of all \`HttpEvent\`s for the request,
* with the response body as a \`Blob\`.
*/
options(url: string, options: {
observe: 'events';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpEvent<Blob>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as a text string
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of all the \`HttpEvent\`s for the request,
* with the response body of type string.
*/
options(url: string, options: {
observe: 'events';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpEvent<string>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as JSON
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of all the \`HttpEvent\`s for the request with the response
* body of type \`Object\`.
*/
options(url: string, options: {
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<Object>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as JSON and
* returns the full event stream.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of all the \`HttpEvent\`s for the request,
* with a response body in the requested type.
*/
options<T>(url: string, options: {
observe: 'events';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpEvent<T>>;
/**
* Constructs an `OPTIONS` request that interprets the body as an `ArrayBuffer`
* and returns the full HTTP response.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An `Observable` of the `HttpResponse` for the request,
* with the response body as an `ArrayBuffer`.
*/
options(url: string, options: {
observe: 'response';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpResponse<ArrayBuffer>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as a \`Blob\`
* and returns the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with the response body as a \`Blob\`.
*/
options(url: string, options: {
observe: 'response';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpResponse<Blob>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as text stream
* and returns the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with the response body of type string.
*/
options(url: string, options: {
observe: 'response';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpResponse<string>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as JSON
* and returns the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with the response body of type \`Object\`.
*/
options(url: string, options: {
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<Object>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as JSON and
* returns the full \`HttpResponse\`.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the \`HttpResponse\` for the request,
* with a response body in the requested type.
*/
options<T>(url: string, options: {
observe: 'response';
responseType?: 'json';
} & HttpClientCommonOptions): Observable<HttpResponse<T>>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as JSON and returns the
* response body as an object parsed from JSON.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the response, with the response body as an object parsed from JSON.
*/
options(url: string, options?: HttpClientCommonOptions): Observable<Object>;
/**
* Constructs an \`OPTIONS\` request that interprets the body as JSON and returns the
* response in a given type.
*
* @param url The endpoint URL.
* @param options HTTP options.
*
* @return An \`Observable\` of the \`HttpResponse\`, with a response body of the given type.
*/
options<T>(url: string, options?: HttpClientCommonOptions): Observable<T>;
/**
* Constructs a `PATCH` request that interprets the body as an `ArrayBuffer` and returns
* the response as an `ArrayBuffer`.
*
* @param url The endpoint URL.
* @param body The resources to edit.
* @param options HTTP options.
*
* @return An `Observable` of the response, with the response body as an `ArrayBuffer`.
*/
patch(url: string, body: any | null, options: {
observe?: 'body';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<ArrayBuffer>;
/**
* Constructs a \`PATCH\` request that interprets the body as a \`Blob\` and returns the response
* as a \`Blob\`.
*
* @param url The endpoint URL.
* @param body The resources to edit.
* @param options HTTP options.
*
* @return An \`Observable\` of the response, with the response body as a \`Blob\`.
*/
patch(url: string, body: any | null, options: {
observe?: 'body';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<Blob>;
/**
* Constructs a \`PATCH\` request that interprets the body as a text string and
* returns the response as a string value.
*
* @param url The endpoint URL.
* @param body The resources to edit.
* @param options HTTP options.
*
* @return An \`Observable\` of the response, with a response body of type string.
*/
patch(url: string, body: any | null, options: {
observe?: 'body';
responseType: 'text';
} & HttpClientCommonOptions): Observable<string>;
/**
* Constructs a `PATCH` request that interprets the body as an `ArrayBuffer` and
* returns the full event stream.
*
* @param url The endpoint URL.
* @param body The resources to edit.
* @param options HTTP options.
*
* @return An `Observable` of all the `HttpEvent`s for the request,
* with the response body as an `ArrayBuffer`.
*/
patch(url: string, body: any | null, options: {
observe: 'events';
responseType: 'arraybuffer';
} & HttpClientCommonOptions): Observable<HttpEvent<ArrayBuffer>>;
/**
* Constructs a `PATCH` request that interprets the body as a `Blob`
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param body The resources to edit.
* @param options HTTP options.
*
* @return An `Observable` of all the `HttpEvent`s for the request, with the
* response body as `Blob`.
*/
patch(url: string, body: any | null, options: {
observe: 'events';
responseType: 'blob';
} & HttpClientCommonOptions): Observable<HttpEvent<Blob>>;
/**
* Constructs a `PATCH` request that interprets the body as a text string and
* returns the full event stream.
*
* @param url The endpoint URL.
* @param body The resources to edit.
* @param options HTTP options.
*
* @return An `Observable` of all the `HttpEvent`s for the request, with a
* response body of type string.
*/
patch(url: string, body: any | null, options: {
observe: 'events';
responseType: 'text';
} & HttpClientCommonOptions): Observable<HttpEvent<string>>;
/**
* Constructs a `PATCH` request that interprets the body as JSON
* and returns the full event stream.
*
* @param url The endpoint URL.
* @param body The resources to edit.
* @param options HTTP options.
*
* @return An `Observable` of all the `HttpEvent`s for the request,
* with a response body of t