adding optional body for HTTP delete request options. This new param added as an optional so won't break the existing code also provide the capability the send the body when and where it required. PR Close #41723
This commit is contained in:
parent
19b12d7286
commit
6b8baad940
|
@ -18,6 +18,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'arraybuffer';
|
responseType: 'arraybuffer';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<ArrayBuffer>;
|
}): Observable<ArrayBuffer>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -31,6 +32,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'blob';
|
responseType: 'blob';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<Blob>;
|
}): Observable<Blob>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -44,6 +46,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'text';
|
responseType: 'text';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<string>;
|
}): Observable<string>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -57,6 +60,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'arraybuffer';
|
responseType: 'arraybuffer';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpEvent<ArrayBuffer>>;
|
}): Observable<HttpEvent<ArrayBuffer>>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -70,6 +74,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'blob';
|
responseType: 'blob';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpEvent<Blob>>;
|
}): Observable<HttpEvent<Blob>>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -83,6 +88,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'text';
|
responseType: 'text';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpEvent<string>>;
|
}): Observable<HttpEvent<string>>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -96,6 +102,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType?: 'json';
|
responseType?: 'json';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpEvent<Object>>;
|
}): Observable<HttpEvent<Object>>;
|
||||||
delete<T>(url: string, options: {
|
delete<T>(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -109,6 +116,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType?: 'json';
|
responseType?: 'json';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpEvent<T>>;
|
}): Observable<HttpEvent<T>>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -122,6 +130,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'arraybuffer';
|
responseType: 'arraybuffer';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpResponse<ArrayBuffer>>;
|
}): Observable<HttpResponse<ArrayBuffer>>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -135,6 +144,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'blob';
|
responseType: 'blob';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpResponse<Blob>>;
|
}): Observable<HttpResponse<Blob>>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -148,6 +158,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType: 'text';
|
responseType: 'text';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpResponse<string>>;
|
}): Observable<HttpResponse<string>>;
|
||||||
delete(url: string, options: {
|
delete(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -161,6 +172,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType?: 'json';
|
responseType?: 'json';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpResponse<Object>>;
|
}): Observable<HttpResponse<Object>>;
|
||||||
delete<T>(url: string, options: {
|
delete<T>(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -174,6 +186,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType?: 'json';
|
responseType?: 'json';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<HttpResponse<T>>;
|
}): Observable<HttpResponse<T>>;
|
||||||
delete(url: string, options?: {
|
delete(url: string, options?: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -187,6 +200,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType?: 'json';
|
responseType?: 'json';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<Object>;
|
}): Observable<Object>;
|
||||||
delete<T>(url: string, options?: {
|
delete<T>(url: string, options?: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
@ -200,6 +214,7 @@ export declare class HttpClient {
|
||||||
reportProgress?: boolean;
|
reportProgress?: boolean;
|
||||||
responseType?: 'json';
|
responseType?: 'json';
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
|
body?: any | null;
|
||||||
}): Observable<T>;
|
}): Observable<T>;
|
||||||
get(url: string, options: {
|
get(url: string, options: {
|
||||||
headers?: HttpHeaders | {
|
headers?: HttpHeaders | {
|
||||||
|
|
|
@ -619,6 +619,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'arraybuffer',
|
reportProgress?: boolean, responseType: 'arraybuffer',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<ArrayBuffer>;
|
}): Observable<ArrayBuffer>;
|
||||||
|
|
||||||
|
|
||||||
|
@ -639,6 +640,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'blob',
|
reportProgress?: boolean, responseType: 'blob',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<Blob>;
|
}): Observable<Blob>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -658,6 +660,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'text',
|
reportProgress?: boolean, responseType: 'text',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<string>;
|
}): Observable<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -677,6 +680,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'arraybuffer',
|
reportProgress?: boolean, responseType: 'arraybuffer',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null
|
||||||
}): Observable<HttpEvent<ArrayBuffer>>;
|
}): Observable<HttpEvent<ArrayBuffer>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -696,6 +700,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'blob',
|
reportProgress?: boolean, responseType: 'blob',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpEvent<Blob>>;
|
}): Observable<HttpEvent<Blob>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -715,6 +720,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'text',
|
reportProgress?: boolean, responseType: 'text',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpEvent<string>>;
|
}): Observable<HttpEvent<string>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -735,6 +741,7 @@ export class HttpClient {
|
||||||
reportProgress?: boolean,
|
reportProgress?: boolean,
|
||||||
responseType?: 'json',
|
responseType?: 'json',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpEvent<Object>>;
|
}): Observable<HttpEvent<Object>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -755,6 +762,7 @@ export class HttpClient {
|
||||||
reportProgress?: boolean,
|
reportProgress?: boolean,
|
||||||
responseType?: 'json',
|
responseType?: 'json',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpEvent<T>>;
|
}): Observable<HttpEvent<T>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -773,6 +781,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'arraybuffer',
|
reportProgress?: boolean, responseType: 'arraybuffer',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpResponse<ArrayBuffer>>;
|
}): Observable<HttpResponse<ArrayBuffer>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -791,6 +800,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'blob',
|
reportProgress?: boolean, responseType: 'blob',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpResponse<Blob>>;
|
}): Observable<HttpResponse<Blob>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -809,6 +819,7 @@ export class HttpClient {
|
||||||
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
{[param: string]: string | number | boolean | ReadonlyArray<string|number|boolean>},
|
||||||
reportProgress?: boolean, responseType: 'text',
|
reportProgress?: boolean, responseType: 'text',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpResponse<string>>;
|
}): Observable<HttpResponse<string>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -829,6 +840,7 @@ export class HttpClient {
|
||||||
reportProgress?: boolean,
|
reportProgress?: boolean,
|
||||||
responseType?: 'json',
|
responseType?: 'json',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpResponse<Object>>;
|
}): Observable<HttpResponse<Object>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -848,6 +860,7 @@ export class HttpClient {
|
||||||
reportProgress?: boolean,
|
reportProgress?: boolean,
|
||||||
responseType?: 'json',
|
responseType?: 'json',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<HttpResponse<T>>;
|
}): Observable<HttpResponse<T>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -868,6 +881,7 @@ export class HttpClient {
|
||||||
reportProgress?: boolean,
|
reportProgress?: boolean,
|
||||||
responseType?: 'json',
|
responseType?: 'json',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<Object>;
|
}): Observable<Object>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -888,6 +902,7 @@ export class HttpClient {
|
||||||
reportProgress?: boolean,
|
reportProgress?: boolean,
|
||||||
responseType?: 'json',
|
responseType?: 'json',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
}): Observable<T>;
|
}): Observable<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -908,6 +923,7 @@ export class HttpClient {
|
||||||
reportProgress?: boolean,
|
reportProgress?: boolean,
|
||||||
responseType?: 'arraybuffer'|'blob'|'json'|'text',
|
responseType?: 'arraybuffer'|'blob'|'json'|'text',
|
||||||
withCredentials?: boolean,
|
withCredentials?: boolean,
|
||||||
|
body?: any|null,
|
||||||
} = {}): Observable<any> {
|
} = {}): Observable<any> {
|
||||||
return this.request<any>('DELETE', url, options as any);
|
return this.request<any>('DELETE', url, options as any);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,30 @@ import {toArray} from 'rxjs/operators';
|
||||||
testReq.flush('hello world');
|
testReq.flush('hello world');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('makes a DELETE request', () => {
|
||||||
|
it('with body', done => {
|
||||||
|
const body = {data: 'json body'};
|
||||||
|
client.delete('/test', {observe: 'response', responseType: 'text', body: body})
|
||||||
|
.subscribe(res => {
|
||||||
|
expect(res.ok).toBeTruthy();
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
const testReq = backend.expectOne('/test');
|
||||||
|
expect(testReq.request.body).toBe(body);
|
||||||
|
testReq.flush('hello world');
|
||||||
|
});
|
||||||
|
it('without body', done => {
|
||||||
|
client.delete('/test', {observe: 'response', responseType: 'text'}).subscribe(res => {
|
||||||
|
expect(res.ok).toBeTruthy();
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
const testReq = backend.expectOne('/test');
|
||||||
|
expect(testReq.request.body).toBe(null);
|
||||||
|
testReq.flush('hello world');
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('makes a JSONP request', () => {
|
describe('makes a JSONP request', () => {
|
||||||
it('with properly set method and callback', done => {
|
it('with properly set method and callback', done => {
|
||||||
client.jsonp('/test', 'myCallback').subscribe(() => done());
|
client.jsonp('/test', 'myCallback').subscribe(() => done());
|
||||||
|
|
Loading…
Reference in New Issue