I noticed that when calling http.request
request(url: string|Request, options?: RequestOptionsArgs): Observable<Response>
the options?: RequestOptionsArgs parameter seems to be ignored if the url: string|Request parameter is of type Request and not string. If it is type Request then this overrides any headers set on the optional options parameter.
Angular version: 2.4.2
Can anyone confirm this? Is this intended behaviour or a bug?
That seems to be correct,
request(url: string|Request, options?: RequestOptionsArgs): Observable<Response> {
let responseObservable: any;
if (typeof url === 'string') {
responseObservable = httpRequest(
this._backend,
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, <string>url)));
} else if (url instanceof Request) {
responseObservable = httpRequest(this._backend, url);
} else {
throw new Error('First argument must be a url string or Request instance.');
}
return responseObservable;
}
Source code: https://github.com/angular/angular/blob/master/packages/http/src/http.ts#L113
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With