feat(common): two missing features in HttpClient (#17996)

- Add params to HttpRequest API
- Add optional description to testing APIs
This commit is contained in:
Alex Rickabaugh 2017-07-07 14:56:36 -07:00 committed by Jason Aden
parent 37797e2b4e
commit c81ad9d19d
14 changed files with 487 additions and 198 deletions

View File

@ -12,7 +12,7 @@ export {HttpHeaders} from './src/headers';
export {HTTP_INTERCEPTORS, HttpInterceptor} from './src/interceptor'; export {HTTP_INTERCEPTORS, HttpInterceptor} from './src/interceptor';
export {JsonpClientBackend, JsonpInterceptor} from './src/jsonp'; export {JsonpClientBackend, JsonpInterceptor} from './src/jsonp';
export {HttpClientJsonpModule, HttpClientModule, interceptingHandler as ɵinterceptingHandler} from './src/module'; export {HttpClientJsonpModule, HttpClientModule, interceptingHandler as ɵinterceptingHandler} from './src/module';
export {HttpParameterCodec, HttpParams, HttpUrlEncodingCodec} from './src/params';
export {HttpRequest} from './src/request'; export {HttpRequest} from './src/request';
export {HttpDownloadProgressEvent, HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaderResponse, HttpProgressEvent, HttpResponse, HttpResponseBase, HttpSentEvent, HttpUserEvent} from './src/response'; export {HttpDownloadProgressEvent, HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaderResponse, HttpProgressEvent, HttpResponse, HttpResponseBase, HttpSentEvent, HttpUserEvent} from './src/response';
export {HttpStandardUrlParameterCodec, HttpUrlEncodedBody, HttpUrlParameterCodec} from './src/url_encoded_body'; export {HttpXhrBackend, XhrFactory} from './src/xhr';
export {HttpXhrBackend, XhrFactory} from './src/xhr';

View File

@ -15,6 +15,7 @@ import {map} from 'rxjs/operator/map';
import {HttpHandler} from './backend'; import {HttpHandler} from './backend';
import {HttpHeaders} from './headers'; import {HttpHeaders} from './headers';
import {HttpParams} from './params';
import {HttpRequest} from './request'; import {HttpRequest} from './request';
import {HttpEvent, HttpEventType, HttpResponse} from './response'; import {HttpEvent, HttpEventType, HttpResponse} from './response';
@ -27,6 +28,7 @@ function addBody<T>(
options: { options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text', responseType?: 'arraybuffer' | 'blob' | 'json' | 'text',
withCredentials?: boolean, withCredentials?: boolean,
}, },
@ -35,6 +37,7 @@ function addBody<T>(
body, body,
headers: options.headers, headers: options.headers,
observe: options.observe, observe: options.observe,
params: options.params,
responseType: options.responseType, responseType: options.responseType,
withCredentials: options.withCredentials, withCredentials: options.withCredentials,
}; };
@ -59,70 +62,75 @@ export class HttpClient {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
params?: HttpParams,
observe: 'events', observe: 'events',
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
request<R>(method: string, url: string, options: { request<R>(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<R>>; }): Observable<HttpEvent<R>>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
request<R>(method: string, url: string, options: { request<R>(method: string, url: string, options: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<R>>; }): Observable<HttpResponse<R>>;
request(method: string, url: string, options?: { request(method: string, url: string, options?: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
@ -130,12 +138,14 @@ export class HttpClient {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<R>; }): Observable<R>;
request(method: string, url: string, options?: { request(method: string, url: string, options?: {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
params?: HttpParams,
observe?: HttpObserve, observe?: HttpObserve,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
@ -175,6 +185,7 @@ export class HttpClient {
body?: any, body?: any,
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {
@ -190,6 +201,7 @@ export class HttpClient {
// provided. // provided.
req = new HttpRequest(first, url !, options.body || null, { req = new HttpRequest(first, url !, options.body || null, {
headers: options.headers, headers: options.headers,
params: options.params,
// By default, JSON is assumed to be returned for all calls. // By default, JSON is assumed to be returned for all calls.
responseType: options.responseType || 'json', responseType: options.responseType || 'json',
withCredentials: options.withCredentials, withCredentials: options.withCredentials,
@ -266,73 +278,78 @@ export class HttpClient {
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
delete<T>(url: string, options: { delete<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
delete<T>(url: string, options: { delete<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
delete (url: string, options?: { delete (url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
delete<T>(url: string, options?: { delete<T>(url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<T>; }): Observable<T>;
@ -344,6 +361,7 @@ export class HttpClient {
delete (url: string, options: { delete (url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {
@ -353,73 +371,78 @@ export class HttpClient {
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
get<T>(url: string, options: { get<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
get<T>(url: string, options: { get<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
get(url: string, options?: { get(url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
get<T>(url: string, options?: { get<T>(url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<T>; }): Observable<T>;
@ -431,6 +454,7 @@ export class HttpClient {
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {
@ -440,73 +464,78 @@ export class HttpClient {
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
head<T>(url: string, options: { head<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
head<T>(url: string, options: { head<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
head(url: string, options?: { head(url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
head<T>(url: string, options?: { head<T>(url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<T>; }): Observable<T>;
@ -518,14 +547,15 @@ export class HttpClient {
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {
return this.request<any>('HEAD', url, options as any); return this.request<any>('HEAD', url, options as any);
} }
jsonp(url: string): Observable<any>; jsonp(url: string, callbackParam: string): Observable<any>;
jsonp<T>(url: string): Observable<T>; jsonp<T>(url: string, callbackParam: string): Observable<T>;
/** /**
* Constructs an `Observable` which, when subscribed, will cause a request * Constructs an `Observable` which, when subscribed, will cause a request
* with the special method `JSONP` to be dispatched via the interceptor pipeline. * with the special method `JSONP` to be dispatched via the interceptor pipeline.
@ -534,8 +564,9 @@ export class HttpClient {
* If no such interceptor is reached, then the `JSONP` request will likely be * If no such interceptor is reached, then the `JSONP` request will likely be
* rejected by the configured backend. * rejected by the configured backend.
*/ */
jsonp<T>(url: string): Observable<T> { jsonp<T>(url: string, callbackParam: string): Observable<T> {
return this.request<any>('JSONP', url, { return this.request<any>('JSONP', url, {
params: new HttpParams().append(callbackParam, 'JSONP_CALLBACK'),
observe: 'body', observe: 'body',
responseType: 'json', responseType: 'json',
}); });
@ -544,73 +575,78 @@ export class HttpClient {
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
options<T>(url: string, options: { options<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
options<T>(url: string, options: { options<T>(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
options(url: string, options?: { options(url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
options<T>(url: string, options?: { options<T>(url: string, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<T>; }): Observable<T>;
@ -622,6 +658,7 @@ export class HttpClient {
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {
@ -631,73 +668,78 @@ export class HttpClient {
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
patch<T>(url: string, body: any|null, options: { patch<T>(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
patch<T>(url: string, body: any|null, options: { patch<T>(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
patch(url: string, body: any|null, options?: { patch(url: string, body: any|null, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
patch<T>(url: string, body: any|null, options?: { patch<T>(url: string, body: any|null, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<T>; }): Observable<T>;
@ -709,6 +751,7 @@ export class HttpClient {
patch(url: string, body: any|null, options: { patch(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {
@ -718,73 +761,78 @@ export class HttpClient {
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
post<T>(url: string, body: any|null, options: { post<T>(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
post<T>(url: string, body: any|null, options: { post<T>(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
post(url: string, body: any|null, options?: { post(url: string, body: any|null, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
post<T>(url: string, body: any|null, options?: { post<T>(url: string, body: any|null, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<T>; }): Observable<T>;
@ -796,6 +844,7 @@ export class HttpClient {
post(url: string, body: any|null, options: { post(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {
@ -805,36 +854,39 @@ export class HttpClient {
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<Blob>; }): Observable<Blob>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<string>; }): Observable<string>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', observe: 'events', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'events', responseType?: 'json', withCredentials?: boolean, observe: 'events', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
put<T>(url: string, body: any|null, options: { put<T>(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
@ -842,36 +894,38 @@ export class HttpClient {
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'arraybuffer', withCredentials?: boolean, responseType: 'arraybuffer', withCredentials?: boolean,
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'blob', withCredentials?: boolean, responseType: 'blob', withCredentials?: boolean,
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', observe: 'response', params?: HttpParams,
responseType: 'text', withCredentials?: boolean, responseType: 'text', withCredentials?: boolean,
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
put<T>(url: string, body: any|null, options: { put<T>(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe: 'response', responseType?: 'json', withCredentials?: boolean, observe: 'response', params?: HttpParams, responseType?: 'json', withCredentials?: boolean,
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
put(url: string, body: any|null, options?: { put(url: string, body: any|null, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<Object>; }): Observable<Object>;
put<T>(url: string, body: any|null, options?: { put<T>(url: string, body: any|null, options?: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: 'body', observe?: 'body',
params?: HttpParams,
responseType?: 'json', responseType?: 'json',
withCredentials?: boolean, withCredentials?: boolean,
}): Observable<T>; }): Observable<T>;
@ -883,6 +937,7 @@ export class HttpClient {
put(url: string, body: any|null, options: { put(url: string, body: any|null, options: {
headers?: HttpHeaders, headers?: HttpHeaders,
observe?: HttpObserve, observe?: HttpObserve,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
} = {}): Observable<any> { } = {}): Observable<any> {

View File

@ -73,7 +73,7 @@ export class JsonpClientBackend implements HttpBackend {
// callback placeholder in the URL with the name. Care has to be taken here to ensure // callback placeholder in the URL with the name. Care has to be taken here to ensure
// a trailing &, if matched, gets inserted back into the URL in the correct place. // a trailing &, if matched, gets inserted back into the URL in the correct place.
const callback = this.nextCallback(); const callback = this.nextCallback();
const url = req.url.replace(/=JSONP_CALLBACK(&|$)/, `=${callback}$1`); const url = req.urlWithParams.replace(/=JSONP_CALLBACK(&|$)/, `=${callback}$1`);
// Construct the <script> tag and point it at the URL. // Construct the <script> tag and point it at the URL.
const node = this.document.createElement('script'); const node = this.document.createElement('script');

View File

@ -9,11 +9,11 @@
/** /**
* A codec for encoding and decoding parameters in URLs. * A codec for encoding and decoding parameters in URLs.
* *
* Used by `HttpUrlEncodedBody`. * Used by `HttpParams`.
* *
* @experimental * @experimental
**/ **/
export interface HttpUrlParameterCodec { export interface HttpParameterCodec {
encodeKey(key: string): string; encodeKey(key: string): string;
encodeValue(value: string): string; encodeValue(value: string): string;
@ -22,12 +22,12 @@ export interface HttpUrlParameterCodec {
} }
/** /**
* A `HttpUrlParameterCodec` that uses `encodeURIComponent` and `decodeURIComponent` to * A `HttpParameterCodec` that uses `encodeURIComponent` and `decodeURIComponent` to
* serialize and parse URL parameter keys and values. * serialize and parse URL parameter keys and values.
* *
* @experimental * @experimental
*/ */
export class HttpStandardUrlParameterCodec implements HttpUrlParameterCodec { export class HttpUrlEncodingCodec implements HttpParameterCodec {
encodeKey(k: string): string { return standardEncoding(k); } encodeKey(k: string): string { return standardEncoding(k); }
encodeValue(v: string): string { return standardEncoding(v); } encodeValue(v: string): string { return standardEncoding(v); }
@ -38,7 +38,7 @@ export class HttpStandardUrlParameterCodec implements HttpUrlParameterCodec {
} }
function paramParser(rawParams: string, codec: HttpUrlParameterCodec): Map<string, string[]> { function paramParser(rawParams: string, codec: HttpParameterCodec): Map<string, string[]> {
const map = new Map<string, string[]>(); const map = new Map<string, string[]>();
if (rawParams.length > 0) { if (rawParams.length > 0) {
const params: string[] = rawParams.split('&'); const params: string[] = rawParams.split('&');
@ -74,25 +74,24 @@ interface Update {
} }
/** /**
* An HTTP request/response body that represents serialized parameters in urlencoded form, * An HTTP request/response body that represents serialized parameters,
* per the MIME type `application/x-www-form-urlencoded`. * per the MIME type `application/x-www-form-urlencoded`.
* *
* This class is immuatable - all mutation operations return a new instance. * This class is immuatable - all mutation operations return a new instance.
* *
* @experimental * @experimental
*/ */
export class HttpUrlEncodedBody { export class HttpParams {
private map: Map<string, string[]>|null; private map: Map<string, string[]>|null;
private encoder: HttpUrlParameterCodec; private encoder: HttpParameterCodec;
private updates: Update[]|null = null; private updates: Update[]|null = null;
private cloneFrom: HttpUrlEncodedBody|null = null; private cloneFrom: HttpParams|null = null;
constructor(options: { constructor(options: {
fromString?: string, fromString?: string,
encoder?: HttpUrlParameterCodec, encoder?: HttpParameterCodec,
} = {}) { } = {}) {
(this as any)['__HttpUrlEncodedBody'] = true; this.encoder = options.encoder || new HttpUrlEncodingCodec();
this.encoder = options.encoder || new HttpStandardUrlParameterCodec();
this.map = !!options.fromString ? paramParser(options.fromString, this.encoder) : null; this.map = !!options.fromString ? paramParser(options.fromString, this.encoder) : null;
} }
@ -124,7 +123,7 @@ export class HttpUrlEncodedBody {
/** /**
* Get all the parameter names for this body. * Get all the parameter names for this body.
*/ */
params(): string[] { keys(): string[] {
this.init(); this.init();
return Array.from(this.map !.keys()); return Array.from(this.map !.keys());
} }
@ -132,25 +131,19 @@ export class HttpUrlEncodedBody {
/** /**
* Construct a new body with an appended value for the given parameter name. * Construct a new body with an appended value for the given parameter name.
*/ */
append(param: string, value: string): HttpUrlEncodedBody { append(param: string, value: string): HttpParams { return this.clone({param, value, op: 'a'}); }
return this.clone({param, value, op: 'a'});
}
/** /**
* Construct a new body with a new value for the given parameter name. * Construct a new body with a new value for the given parameter name.
*/ */
set(param: string, value: string): HttpUrlEncodedBody { set(param: string, value: string): HttpParams { return this.clone({param, value, op: 's'}); }
return this.clone({param, value, op: 's'});
}
/** /**
* Construct a new body with either the given value for the given parameter * Construct a new body with either the given value for the given parameter
* removed, if a value is given, or all values for the given parameter removed * removed, if a value is given, or all values for the given parameter removed
* if not. * if not.
*/ */
delete (param: string, value?: string): HttpUrlEncodedBody { delete (param: string, value?: string): HttpParams { return this.clone({param, value, op: 'd'}); }
return this.clone({param, value, op: 'd'});
}
/** /**
* Serialize the body to an encoded string, where key-value pairs (separated by `=`) are * Serialize the body to an encoded string, where key-value pairs (separated by `=`) are
@ -158,7 +151,7 @@ export class HttpUrlEncodedBody {
*/ */
toString(): string { toString(): string {
this.init(); this.init();
return this.params() return this.keys()
.map(key => { .map(key => {
const eKey = this.encoder.encodeKey(key); const eKey = this.encoder.encodeKey(key);
return this.map !.get(key) !.map(value => eKey + '=' + this.encoder.encodeValue(value)) return this.map !.get(key) !.map(value => eKey + '=' + this.encoder.encodeValue(value))
@ -167,8 +160,8 @@ export class HttpUrlEncodedBody {
.join('&'); .join('&');
} }
private clone(update: Update): HttpUrlEncodedBody { private clone(update: Update): HttpParams {
const clone = new HttpUrlEncodedBody({encoder: this.encoder}); const clone = new HttpParams({encoder: this.encoder});
clone.cloneFrom = this.cloneFrom || this; clone.cloneFrom = this.cloneFrom || this;
clone.updates = (this.updates || []).concat([update]); clone.updates = (this.updates || []).concat([update]);
return clone; return clone;
@ -180,8 +173,7 @@ export class HttpUrlEncodedBody {
} }
if (this.cloneFrom !== null) { if (this.cloneFrom !== null) {
this.cloneFrom.init(); this.cloneFrom.init();
this.cloneFrom.params().forEach( this.cloneFrom.keys().forEach(key => this.map !.set(key, this.cloneFrom !.map !.get(key) !));
key => this.map !.set(key, this.cloneFrom !.map !.get(key) !));
this.updates !.forEach(update => { this.updates !.forEach(update => {
switch (update.op) { switch (update.op) {
case 'a': case 'a':

View File

@ -7,6 +7,7 @@
*/ */
import {HttpHeaders} from './headers'; import {HttpHeaders} from './headers';
import {HttpParams} from './params';
/** /**
* Construction interface for `HttpRequest`s. * Construction interface for `HttpRequest`s.
@ -14,7 +15,7 @@ import {HttpHeaders} from './headers';
* All values are optional and will override default values if provided. * All values are optional and will override default values if provided.
*/ */
interface HttpRequestInit { interface HttpRequestInit {
headers?: HttpHeaders, reportProgress?: boolean, headers?: HttpHeaders, reportProgress?: boolean, params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', withCredentials?: boolean, responseType?: 'arraybuffer'|'blob'|'json'|'text', withCredentials?: boolean,
} }
@ -61,10 +62,6 @@ function isFormData(value: any): value is FormData {
return typeof FormData !== 'undefined' && value instanceof FormData; return typeof FormData !== 'undefined' && value instanceof FormData;
} }
function isUrlEncodedBody(value: any): value is Object {
return typeof value === 'object' && value['__HttpUrlEncodedBody'];
}
/** /**
* An outgoing HTTP request with an optional typed body. * An outgoing HTTP request with an optional typed body.
* *
@ -116,34 +113,49 @@ export class HttpRequest<T> {
*/ */
readonly method: string; readonly method: string;
/**
* Outgoing URL parameters.
*/
readonly params: HttpParams;
/**
* The outgoing URL with all URL parameters set.
*/
readonly urlWithParams: string;
constructor(method: 'DELETE'|'GET'|'HEAD'|'JSONP'|'OPTIONS', url: string, init?: { constructor(method: 'DELETE'|'GET'|'HEAD'|'JSONP'|'OPTIONS', url: string, init?: {
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
}); });
constructor(method: 'POST'|'PUT'|'PATCH', url: string, body: T|null, init?: { constructor(method: 'POST'|'PUT'|'PATCH', url: string, body: T|null, init?: {
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
}); });
constructor(method: string, url: string, body: T|null, init?: { constructor(method: string, url: string, body: T|null, init?: {
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
}); });
constructor( constructor(
method: string, public url: string, third?: T|{ method: string, readonly url: string, third?: T|{
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
}|null, }|null,
fourth?: { fourth?: {
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
}) { }) {
@ -178,12 +190,41 @@ export class HttpRequest<T> {
if (!!options.headers) { if (!!options.headers) {
this.headers = options.headers; this.headers = options.headers;
} }
if (!!options.params) {
this.params = options.params;
}
} }
// If no headers have been passed in, construct a new HttpHeaders instance. // If no headers have been passed in, construct a new HttpHeaders instance.
if (!this.headers) { if (!this.headers) {
this.headers = new HttpHeaders(); this.headers = new HttpHeaders();
} }
// If no parameters have been passed in, construct a new HttpUrlEncodedParams instance.
if (!this.params) {
this.params = new HttpParams();
this.urlWithParams = url;
} else {
// Encode the parameters to a string in preparation for inclusion in the URL.
const params = this.params.toString();
if (params.length === 0) {
// No parameters, the visible URL is just the URL given at creation time.
this.urlWithParams = url;
} else {
// Does the URL already have query parameters? Look for '?'.
const qIdx = url.indexOf('?');
// There are 3 cases to handle:
// 1) No existing parameters -> append '?' followed by params.
// 2) '?' exists and is followed by existing query string ->
// append '&' followed by params.
// 3) '?' exists at the end of the url -> append params directly.
// This basically amounts to determining the character, if any, with
// which to join the URL and parameters.
const sep: string = qIdx === -1 ? '?' : (qIdx < url.length - 1 ? '&' : '');
this.urlWithParams = url + sep + params;
}
}
} }
/** /**
@ -201,9 +242,8 @@ export class HttpRequest<T> {
typeof this.body === 'string') { typeof this.body === 'string') {
return this.body; return this.body;
} }
// Check whether the body is an instance of HttpUrlEncodedBody, avoiding any direct // Check whether the body is an instance of HttpUrlEncodedParams.
// references to the class in order to permit it being tree-shaken. if (this.body instanceof HttpParams) {
if (isUrlEncodedBody(this.body)) {
return this.body.toString(); return this.body.toString();
} }
// Check whether the body is an object or array, and serialize with JSON if so. // Check whether the body is an object or array, and serialize with JSON if so.
@ -244,9 +284,8 @@ export class HttpRequest<T> {
if (typeof this.body === 'string') { if (typeof this.body === 'string') {
return 'text/plain'; return 'text/plain';
} }
// `HttpUrlEncodedBody` is detected specially so as to allow it to be // `HttpUrlEncodedParams` has its own content-type.
// tree-shaken. if (this.body instanceof HttpParams) {
if (isUrlEncodedBody(this.body)) {
return 'application/x-www-form-urlencoded;charset=UTF-8'; return 'application/x-www-form-urlencoded;charset=UTF-8';
} }
// Arrays, objects, and numbers will be encoded as JSON. // Arrays, objects, and numbers will be encoded as JSON.
@ -262,28 +301,38 @@ export class HttpRequest<T> {
clone(update: { clone(update: {
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
body?: T|null,
method?: string,
url?: string,
setHeaders?: {[name: string]: string | string[]},
setParams?: {[param: string]: string},
}): HttpRequest<T>; }): HttpRequest<T>;
clone<V>(update: { clone<V>(update: {
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
body?: V|null, body?: V|null,
method?: string, method?: string,
url?: string, url?: string,
setHeaders?: {[name: string]: string | string[]}, setHeaders?: {[name: string]: string | string[]},
setParams?: {[param: string]: string},
}): HttpRequest<V>; }): HttpRequest<V>;
clone(update: { clone(update: {
headers?: HttpHeaders, headers?: HttpHeaders,
reportProgress?: boolean, reportProgress?: boolean,
params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', responseType?: 'arraybuffer'|'blob'|'json'|'text',
withCredentials?: boolean, withCredentials?: boolean,
body?: any|null, body?: any|null,
method?: string, method?: string,
url?: string, url?: string,
setHeaders?: {[name: string]: string | string[]}, setHeaders?: {[name: string]: string | string[]},
setParams?: {[param: string]: string};
} = {}): HttpRequest<any> { } = {}): HttpRequest<any> {
// For method, url, and responseType, take the current value unless // For method, url, and responseType, take the current value unless
// it is overridden in the update hash. // it is overridden in the update hash.
@ -304,9 +353,10 @@ export class HttpRequest<T> {
const reportProgress = const reportProgress =
(update.reportProgress !== undefined) ? update.reportProgress : this.reportProgress; (update.reportProgress !== undefined) ? update.reportProgress : this.reportProgress;
// Headers may need to be cloned later if they're sealed, but being // Headers and params may be appended to if `setHeaders` or
// appended to. // `setParams` are used.
let headers = update.headers || this.headers; let headers = update.headers || this.headers;
let params = update.params || this.params;
// Check whether the caller has asked to add headers. // Check whether the caller has asked to add headers.
if (update.setHeaders !== undefined) { if (update.setHeaders !== undefined) {
@ -316,10 +366,17 @@ export class HttpRequest<T> {
.reduce((headers, name) => headers.set(name, update.setHeaders ![name]), headers); .reduce((headers, name) => headers.set(name, update.setHeaders ![name]), headers);
} }
// Check whether the caller has asked to set params.
if (update.setParams) {
// Set every requested param.
params = Object.keys(update.setParams)
.reduce((params, param) => params.set(param, update.setParams ![param]), params);
}
// Finally, construct the new HttpRequest using the pieces from above. // Finally, construct the new HttpRequest using the pieces from above.
return new HttpRequest( return new HttpRequest(
method, url, body, { method, url, body, {
headers, reportProgress, responseType, withCredentials, params, headers, reportProgress, responseType, withCredentials,
}); });
} }
} }

View File

@ -83,7 +83,7 @@ export class HttpXhrBackend implements HttpBackend {
return new Observable((observer: Observer<HttpEvent<any>>) => { return new Observable((observer: Observer<HttpEvent<any>>) => {
// Start by setting up the XHR object with request method, URL, and withCredentials flag. // Start by setting up the XHR object with request method, URL, and withCredentials flag.
const xhr = this.xhrFactory.build(); const xhr = this.xhrFactory.build();
xhr.open(req.method, req.url); xhr.open(req.method, req.urlWithParams);
if (!!req.withCredentials) { if (!!req.withCredentials) {
xhr.withCredentials = true; xhr.withCredentials = true;
} }

View File

@ -110,5 +110,12 @@ export function main() {
testReq.flush('hello world'); testReq.flush('hello world');
}); });
}); });
describe('makes a JSONP request', () => {
it('with properly set method and callback', (done: DoneFn) => {
client.jsonp('/test', 'myCallback').subscribe(() => done());
backend.expectOne({method: 'JSONP', url: '/test?myCallback=JSONP_CALLBACK'})
.flush('hello world');
});
});
}); });
} }

View File

@ -6,18 +6,18 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {HttpUrlEncodedBody} from '../src/url_encoded_body'; import {HttpParams} from '../src/params';
export function main() { export function main() {
describe('HttpUrlEncodedBody', () => { describe('HttpUrlEncodedParams', () => {
describe('initialization', () => { describe('initialization', () => {
it('should be empty at construction', () => { it('should be empty at construction', () => {
const body = new HttpUrlEncodedBody(); const body = new HttpParams();
expect(body.toString()).toEqual('') expect(body.toString()).toEqual('')
}); });
it('should parse an existing url', () => { it('should parse an existing url', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=b&c=d&c=e'}); const body = new HttpParams({fromString: 'a=b&c=d&c=e'});
expect(body.getAll('a')).toEqual(['b']); expect(body.getAll('a')).toEqual(['b']);
expect(body.getAll('c')).toEqual(['d', 'e']); expect(body.getAll('c')).toEqual(['d', 'e']);
}); });
@ -25,31 +25,31 @@ export function main() {
describe('lazy mutation', () => { describe('lazy mutation', () => {
it('should allow setting parameters', () => { it('should allow setting parameters', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=b'}); const body = new HttpParams({fromString: 'a=b'});
const mutated = body.set('a', 'c'); const mutated = body.set('a', 'c');
expect(mutated.toString()).toEqual('a=c'); expect(mutated.toString()).toEqual('a=c');
}); });
it('should allow appending parameters', () => { it('should allow appending parameters', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=b'}); const body = new HttpParams({fromString: 'a=b'});
const mutated = body.append('a', 'c'); const mutated = body.append('a', 'c');
expect(mutated.toString()).toEqual('a=b&a=c'); expect(mutated.toString()).toEqual('a=b&a=c');
}); });
it('should allow deletion of parameters', () => { it('should allow deletion of parameters', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=b&c=d&e=f'}); const body = new HttpParams({fromString: 'a=b&c=d&e=f'});
const mutated = body.delete('c'); const mutated = body.delete('c');
expect(mutated.toString()).toEqual('a=b&e=f'); expect(mutated.toString()).toEqual('a=b&e=f');
}); });
it('should allow chaining of mutations', () => { it('should allow chaining of mutations', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=b&c=d&e=f'}); const body = new HttpParams({fromString: 'a=b&c=d&e=f'});
const mutated = body.append('e', 'y').delete('c').set('a', 'x').append('e', 'z'); const mutated = body.append('e', 'y').delete('c').set('a', 'x').append('e', 'z');
expect(mutated.toString()).toEqual('a=x&e=f&e=y&e=z'); expect(mutated.toString()).toEqual('a=x&e=f&e=y&e=z');
}); });
it('should allow deletion of one value of a parameter', () => { it('should allow deletion of one value of a parameter', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=1&a=2&a=3&a=4&a=5'}); const body = new HttpParams({fromString: 'a=1&a=2&a=3&a=4&a=5'});
const mutated = body.delete('a', '2').delete('a', '4'); const mutated = body.delete('a', '2').delete('a', '4');
expect(mutated.getAll('a')).toEqual(['1', '3', '5']); expect(mutated.getAll('a')).toEqual(['1', '3', '5']);
}); });
@ -57,20 +57,15 @@ export function main() {
describe('read operations', () => { describe('read operations', () => {
it('should give null if parameter is not set', () => { it('should give null if parameter is not set', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=b&c=d'}); const body = new HttpParams({fromString: 'a=b&c=d'});
expect(body.get('e')).toBeNull(); expect(body.get('e')).toBeNull();
expect(body.getAll('e')).toBeNull(); expect(body.getAll('e')).toBeNull();
}); });
it('should give an accurate list of keys', () => { it('should give an accurate list of keys', () => {
const body = new HttpUrlEncodedBody({fromString: 'a=1&b=2&c=3&d=4'}); const body = new HttpParams({fromString: 'a=1&b=2&c=3&d=4'});
expect(body.params()).toEqual(['a', 'b', 'c', 'd']); expect(body.keys()).toEqual(['a', 'b', 'c', 'd']);
}); });
}); });
it('should have a magic Symbol-like property', () => {
const body = new HttpUrlEncodedBody() as any;
expect(body['__HttpUrlEncodedBody']).toEqual(true);
});
}); });
} }

View File

@ -9,6 +9,7 @@
import {ddescribe, describe, it} from '@angular/core/testing/src/testing_internal'; import {ddescribe, describe, it} from '@angular/core/testing/src/testing_internal';
import {HttpHeaders} from '../src/headers'; import {HttpHeaders} from '../src/headers';
import {HttpParams} from '../src/params';
import {HttpRequest} from '../src/request'; import {HttpRequest} from '../src/request';
const TEST_URL = 'http://angular.io'; const TEST_URL = 'http://angular.io';
@ -131,6 +132,33 @@ export function main() {
const req = baseReq.clone({body: {data: 'test data'}}); const req = baseReq.clone({body: {data: 'test data'}});
expect(req.serializeBody()).toBe('{"data":"test data"}'); expect(req.serializeBody()).toBe('{"data":"test data"}');
}); });
it('serializes parameters as urlencoded', () => {
const params = new HttpParams().append('first', 'value').append('second', 'other');
const withParams = baseReq.clone({body: params});
expect(withParams.serializeBody()).toEqual('first=value&second=other');
expect(withParams.detectContentTypeHeader())
.toEqual('application/x-www-form-urlencoded;charset=UTF-8');
});
});
describe('parameter handling', () => {
const baseReq = new HttpRequest('GET', '/test', null);
const params = new HttpParams({fromString: 'test=true'});
it('appends parameters to a base URL', () => {
const req = baseReq.clone({params});
expect(req.urlWithParams).toEqual('/test?test=true');
});
it('appends parameters to a URL with an empty query string', () => {
const req = baseReq.clone({params, url: '/test?'});
expect(req.urlWithParams).toEqual('/test?test=true');
});
it('appends parameters to a URL with a query string', () => {
const req = baseReq.clone({params, url: '/test?other=false'});
expect(req.urlWithParams).toEqual('/test?other=false&test=true');
});
it('sets parameters via setParams', () => {
const req = baseReq.clone({setParams: {'test': 'false'}});
expect(req.urlWithParams).toEqual('/test?test=false');
});
}); });
}); });
} }

View File

@ -33,16 +33,16 @@ export abstract class HttpTestingController {
abstract match(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): TestRequest[]; abstract match(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): TestRequest[];
// Expect that exactly one request matches the given parameter. // Expect that exactly one request matches the given parameter.
abstract expectOne(url: string): TestRequest; abstract expectOne(url: string, description?: string): TestRequest;
abstract expectOne(params: RequestMatch): TestRequest; abstract expectOne(params: RequestMatch, description?: string): TestRequest;
abstract expectOne(matchFn: ((req: HttpRequest<any>) => boolean)): TestRequest; abstract expectOne(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
abstract expectOne(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): TestRequest; abstract expectOne(match: string|RequestMatch|((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
// Assert that no requests match the given parameter. // Assert that no requests match the given parameter.
abstract expectNone(url: string): void; abstract expectNone(url: string, description?: string): void;
abstract expectNone(params: RequestMatch): void; abstract expectNone(params: RequestMatch, description?: string): void;
abstract expectNone(matchFn: ((req: HttpRequest<any>) => boolean)): void; abstract expectNone(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): void;
abstract expectNone(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): void; abstract expectNone(match: string|RequestMatch|((req: HttpRequest<any>) => boolean), description?: string): void;
// Validate that all requests which were issued were flushed. // Validate that all requests which were issued were flushed.
abstract verify(opts?: {ignoreCancelled?: boolean}): void; abstract verify(opts?: {ignoreCancelled?: boolean}): void;

View File

@ -51,13 +51,13 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl
*/ */
private _match(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): TestRequest[] { private _match(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): TestRequest[] {
if (typeof match === 'string') { if (typeof match === 'string') {
return this.open.filter(testReq => testReq.request.url === match); return this.open.filter(testReq => testReq.request.urlWithParams === match);
} else if (typeof match === 'function') { } else if (typeof match === 'function') {
return this.open.filter(testReq => match(testReq.request)); return this.open.filter(testReq => match(testReq.request));
} else { } else {
return this.open.filter( return this.open.filter(
testReq => (!match.method || testReq.request.method === match.method.toUpperCase()) && testReq => (!match.method || testReq.request.method === match.method.toUpperCase()) &&
(!match.url || testReq.request.url === match.url)); (!match.url || testReq.request.urlWithParams === match.url));
} }
} }
@ -83,13 +83,14 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl
* Requests returned through this API will no longer be in the list of open requests, * Requests returned through this API will no longer be in the list of open requests,
* and thus will not match twice. * and thus will not match twice.
*/ */
expectOne(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): TestRequest { expectOne(match: string|RequestMatch|((req: HttpRequest<any>) => boolean), description?: string): TestRequest {
description = description || this.descriptionFromMatcher(match);
const matches = this.match(match); const matches = this.match(match);
if (matches.length > 1) { if (matches.length > 1) {
throw new Error(`Expected one matching request, found ${matches.length} requests.`); throw new Error(`Expected one matching request for criteria "${description}", found ${matches.length} requests.`);
} }
if (matches.length === 0) { if (matches.length === 0) {
throw new Error(`Expected one matching request, found none.`); throw new Error(`Expected one matching request for criteria "${description}", found none.`);
} }
return matches[0]; return matches[0];
} }
@ -98,10 +99,11 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl
* Expect that no outstanding requests match the given matcher, and throw an error * Expect that no outstanding requests match the given matcher, and throw an error
* if any do. * if any do.
*/ */
expectNone(match: string|RequestMatch|((req: HttpRequest<any>) => boolean)): void { expectNone(match: string|RequestMatch|((req: HttpRequest<any>) => boolean), description?: string): void {
description = description || this.descriptionFromMatcher(match);
const matches = this.match(match); const matches = this.match(match);
if (matches.length > 0) { if (matches.length > 0) {
throw new Error(`Expected zero matching requests, found ${matches.length}.`); throw new Error(`Expected zero matching requests for criteria "${description}", found ${matches.length}.`);
} }
} }
@ -116,9 +118,25 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl
open = open.filter(testReq => !testReq.cancelled); open = open.filter(testReq => !testReq.cancelled);
} }
if (open.length > 0) { if (open.length > 0) {
// Show the URLs of open requests in the error, for convenience. // Show the methods and URLs of open requests in the error, for convenience.
const urls = open.map(testReq => testReq.request.url.split('?')[0]).join(', '); const requests = open.map(testReq => {
throw new Error(`Expected no open requests, found ${open.length}: ${urls}`); const url = testReq.request.urlWithParams.split('?')[0];
const method = testReq.request.method;
return `${method} ${url}`
}).join(', ');
throw new Error(`Expected no open requests, found ${open.length}: ${requests}`);
}
}
private descriptionFromMatcher(matcher: string|RequestMatch|((req: HttpRequest<any>) => boolean)): string {
if (typeof matcher === 'string') {
return `Match URL: ${matcher}`;
} else if (typeof matcher === 'object') {
const method = matcher.method || '(any)';
const url = matcher.url || '(any)';
return `Match method: ${method}, URL: ${url}`;
} else {
return `Match by function: ${matcher.name}`;
} }
} }
} }

View File

@ -39,7 +39,7 @@ export class TestRequest {
if (this.cancelled) { if (this.cancelled) {
throw new Error(`Cannot flush a cancelled request.`); throw new Error(`Cannot flush a cancelled request.`);
} }
const url = this.request.url; const url = this.request.urlWithParams;
const headers = const headers =
(opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers); (opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers);
body = _maybeConvertBody(this.request.responseType, body); body = _maybeConvertBody(this.request.responseType, body);
@ -83,7 +83,7 @@ export class TestRequest {
headers, headers,
status: opts.status || 0, status: opts.status || 0,
statusText: opts.statusText || '', statusText: opts.statusText || '',
url: this.request.url, url: this.request.urlWithParams,
})); }));
} }

View File

@ -12,578 +12,674 @@ export declare class HttpClient {
delete<T>(url: string, options?: { delete<T>(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T>; }): Observable<T>;
delete(url: string, options?: { delete(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
delete<T>(url: string, options: { delete<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
delete<T>(url: string, options: { delete<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
delete(url: string, options: { delete(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
get<T>(url: string, options: { get<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
get(url: string, options: { get(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
get<T>(url: string, options: { get<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
get(url: string, options?: { get(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
get<T>(url: string, options?: { get<T>(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T>; }): Observable<T>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
head<T>(url: string, options: { head<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
head<T>(url: string, options: { head<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
head(url: string, options?: { head(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
head<T>(url: string, options?: { head<T>(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T>; }): Observable<T>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
head(url: string, options: { head(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
jsonp(url: string): Observable<any>; jsonp(url: string, callbackParam: string): Observable<any>;
jsonp<T>(url: string): Observable<T>; jsonp<T>(url: string, callbackParam: string): Observable<T>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
options<T>(url: string, options: { options<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
options(url: string, options: { options(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
options<T>(url: string, options: { options<T>(url: string, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
options(url: string, options?: { options(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
options<T>(url: string, options?: { options<T>(url: string, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T>; }): Observable<T>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
patch<T>(url: string, body: any | null, options: { patch<T>(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
patch(url: string, body: any | null, options: { patch(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
patch<T>(url: string, body: any | null, options: { patch<T>(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
patch(url: string, body: any | null, options?: { patch(url: string, body: any | null, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
patch<T>(url: string, body: any | null, options?: { patch<T>(url: string, body: any | null, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T>; }): Observable<T>;
post<T>(url: string, body: any | null, options: { post<T>(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<T>>; }): Observable<HttpEvent<T>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
post(url: string, body: any | null, options: { post(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
post<T>(url: string, body: any | null, options: { post<T>(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
post(url: string, body: any | null, options?: { post(url: string, body: any | null, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
post<T>(url: string, body: any | null, options?: { post<T>(url: string, body: any | null, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T>; }): Observable<T>;
put(url: string, body: any | null, options?: { put(url: string, body: any | null, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
put<T>(url: string, body: any | null, options: { put<T>(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<T>>; }): Observable<HttpResponse<T>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Object>>; }): Observable<HttpResponse<Object>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
@ -596,48 +692,56 @@ export declare class HttpClient {
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Object>>; }): Observable<HttpEvent<Object>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<ArrayBuffer>>; }): Observable<HttpEvent<ArrayBuffer>>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
put(url: string, body: any | null, options: { put(url: string, body: any | null, options: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
put<T>(url: string, body: any | null, options?: { put<T>(url: string, body: any | null, options?: {
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<T>; }): Observable<T>;
@ -645,6 +749,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<string>>; }): Observable<HttpEvent<string>>;
@ -652,6 +757,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<R>; }): Observable<R>;
@ -659,6 +765,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<ArrayBuffer>; }): Observable<ArrayBuffer>;
@ -666,6 +773,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Blob>; }): Observable<Blob>;
@ -673,12 +781,14 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<string>; }): Observable<string>;
request(method: string, url: string, options: { request(method: string, url: string, options: {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
params?: HttpParams;
observe: 'events'; observe: 'events';
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
@ -687,6 +797,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<Blob>>; }): Observable<HttpEvent<Blob>>;
@ -695,6 +806,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'events'; observe: 'events';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpEvent<R>>; }): Observable<HttpEvent<R>>;
@ -702,6 +814,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'arraybuffer'; responseType: 'arraybuffer';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<ArrayBuffer>>; }): Observable<HttpResponse<ArrayBuffer>>;
@ -709,6 +822,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'blob'; responseType: 'blob';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<Blob>>; }): Observable<HttpResponse<Blob>>;
@ -716,6 +830,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType: 'text'; responseType: 'text';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<string>>; }): Observable<HttpResponse<string>>;
@ -723,6 +838,7 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe: 'response'; observe: 'response';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<HttpResponse<R>>; }): Observable<HttpResponse<R>>;
@ -730,12 +846,14 @@ export declare class HttpClient {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
observe?: 'body'; observe?: 'body';
params?: HttpParams;
responseType?: 'json'; responseType?: 'json';
withCredentials?: boolean; withCredentials?: boolean;
}): Observable<Object>; }): Observable<Object>;
request(method: string, url: string, options?: { request(method: string, url: string, options?: {
body?: any; body?: any;
headers?: HttpHeaders; headers?: HttpHeaders;
params?: HttpParams;
observe?: HttpObserve; observe?: HttpObserve;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean; withCredentials?: boolean;
@ -825,6 +943,30 @@ export interface HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>; intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
} }
/** @experimental */
export interface HttpParameterCodec {
decodeKey(key: string): string;
decodeValue(value: string): string;
encodeKey(key: string): string;
encodeValue(value: string): string;
}
/** @experimental */
export declare class HttpParams {
constructor(options?: {
fromString?: string;
encoder?: HttpParameterCodec;
});
append(param: string, value: string): HttpParams;
delete(param: string, value?: string): HttpParams;
get(param: string): string | null;
getAll(param: string): string[] | null;
has(param: string): boolean;
keys(): string[];
set(param: string, value: string): HttpParams;
toString(): string;
}
/** @experimental */ /** @experimental */
export interface HttpProgressEvent { export interface HttpProgressEvent {
loaded: number; loaded: number;
@ -837,25 +979,30 @@ export declare class HttpRequest<T> {
readonly body: T | null; readonly body: T | null;
readonly headers: HttpHeaders; readonly headers: HttpHeaders;
readonly method: string; readonly method: string;
readonly params: HttpParams;
readonly reportProgress: boolean; readonly reportProgress: boolean;
readonly responseType: 'arraybuffer' | 'blob' | 'json' | 'text'; readonly responseType: 'arraybuffer' | 'blob' | 'json' | 'text';
url: string; readonly url: string;
readonly urlWithParams: string;
readonly withCredentials: boolean; readonly withCredentials: boolean;
constructor(method: 'DELETE' | 'GET' | 'HEAD' | 'JSONP' | 'OPTIONS', url: string, init?: { constructor(method: 'DELETE' | 'GET' | 'HEAD' | 'JSONP' | 'OPTIONS', url: string, init?: {
headers?: HttpHeaders; headers?: HttpHeaders;
reportProgress?: boolean; reportProgress?: boolean;
params?: HttpParams;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean; withCredentials?: boolean;
}); });
constructor(method: 'POST' | 'PUT' | 'PATCH', url: string, body: T | null, init?: { constructor(method: 'POST' | 'PUT' | 'PATCH', url: string, body: T | null, init?: {
headers?: HttpHeaders; headers?: HttpHeaders;
reportProgress?: boolean; reportProgress?: boolean;
params?: HttpParams;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean; withCredentials?: boolean;
}); });
constructor(method: string, url: string, body: T | null, init?: { constructor(method: string, url: string, body: T | null, init?: {
headers?: HttpHeaders; headers?: HttpHeaders;
reportProgress?: boolean; reportProgress?: boolean;
params?: HttpParams;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean; withCredentials?: boolean;
}); });
@ -863,12 +1010,23 @@ export declare class HttpRequest<T> {
clone(update: { clone(update: {
headers?: HttpHeaders; headers?: HttpHeaders;
reportProgress?: boolean; reportProgress?: boolean;
params?: HttpParams;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean; withCredentials?: boolean;
body?: T | null;
method?: string;
url?: string;
setHeaders?: {
[name: string]: string | string[];
};
setParams?: {
[param: string]: string;
};
}): HttpRequest<T>; }): HttpRequest<T>;
clone<V>(update: { clone<V>(update: {
headers?: HttpHeaders; headers?: HttpHeaders;
reportProgress?: boolean; reportProgress?: boolean;
params?: HttpParams;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
withCredentials?: boolean; withCredentials?: boolean;
body?: V | null; body?: V | null;
@ -877,6 +1035,9 @@ export declare class HttpRequest<T> {
setHeaders?: { setHeaders?: {
[name: string]: string | string[]; [name: string]: string | string[];
}; };
setParams?: {
[param: string]: string;
};
}): HttpRequest<V>; }): HttpRequest<V>;
detectContentTypeHeader(): string | null; detectContentTypeHeader(): string | null;
serializeBody(): ArrayBuffer | Blob | FormData | string | null; serializeBody(): ArrayBuffer | Blob | FormData | string | null;
@ -931,37 +1092,13 @@ export interface HttpSentEvent {
} }
/** @experimental */ /** @experimental */
export declare class HttpStandardUrlParameterCodec implements HttpUrlParameterCodec { export declare class HttpUrlEncodingCodec implements HttpParameterCodec {
decodeKey(k: string): string; decodeKey(k: string): string;
decodeValue(v: string): string; decodeValue(v: string): string;
encodeKey(k: string): string; encodeKey(k: string): string;
encodeValue(v: string): string; encodeValue(v: string): string;
} }
/** @experimental */
export declare class HttpUrlEncodedBody {
constructor(options?: {
fromString?: string;
encoder?: HttpUrlParameterCodec;
});
append(param: string, value: string): HttpUrlEncodedBody;
delete(param: string, value?: string): HttpUrlEncodedBody;
get(param: string): string | null;
getAll(param: string): string[] | null;
has(param: string): boolean;
params(): string[];
set(param: string, value: string): HttpUrlEncodedBody;
toString(): string;
}
/** @experimental */
export interface HttpUrlParameterCodec {
decodeKey(key: string): string;
decodeValue(value: string): string;
encodeKey(key: string): string;
encodeValue(value: string): string;
}
/** @experimental */ /** @experimental */
export interface HttpUserEvent<T> { export interface HttpUserEvent<T> {
type: HttpEventType.User; type: HttpEventType.User;

View File

@ -4,14 +4,14 @@ export declare class HttpClientTestingModule {
/** @experimental */ /** @experimental */
export declare abstract class HttpTestingController { export declare abstract class HttpTestingController {
abstract expectNone(url: string): void; abstract expectNone(url: string, description?: string): void;
abstract expectNone(params: RequestMatch): void; abstract expectNone(params: RequestMatch, description?: string): void;
abstract expectNone(matchFn: ((req: HttpRequest<any>) => boolean)): void; abstract expectNone(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): void;
abstract expectNone(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): void; abstract expectNone(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): void;
abstract expectOne(url: string): TestRequest; abstract expectOne(url: string, description?: string): TestRequest;
abstract expectOne(params: RequestMatch): TestRequest; abstract expectOne(params: RequestMatch, description?: string): TestRequest;
abstract expectOne(matchFn: ((req: HttpRequest<any>) => boolean)): TestRequest; abstract expectOne(matchFn: ((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
abstract expectOne(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest; abstract expectOne(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean), description?: string): TestRequest;
abstract match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[]; abstract match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[];
abstract verify(opts?: { abstract verify(opts?: {
ignoreCancelled?: boolean; ignoreCancelled?: boolean;