
committed by
Miško Hevery

parent
1ae77da609
commit
6ab5f3648a
@ -25,7 +25,7 @@ export abstract class Body {
|
||||
*/
|
||||
json(): any {
|
||||
if (typeof this._body === 'string') {
|
||||
return JSON.parse(<string>this._body);
|
||||
return JSON.parse(this._body);
|
||||
}
|
||||
|
||||
if (this._body instanceof ArrayBuffer) {
|
||||
@ -57,9 +57,9 @@ export abstract class Body {
|
||||
if (this._body instanceof ArrayBuffer) {
|
||||
switch (encodingHint) {
|
||||
case 'legacy':
|
||||
return String.fromCharCode.apply(null, new Uint16Array(this._body as ArrayBuffer));
|
||||
return String.fromCharCode.apply(null, new Uint16Array(this._body));
|
||||
case 'iso-8859':
|
||||
return String.fromCharCode.apply(null, new Uint8Array(this._body as ArrayBuffer));
|
||||
return String.fromCharCode.apply(null, new Uint8Array(this._body));
|
||||
default:
|
||||
throw new Error(`Invalid value for encodingHint: ${encodingHint}`);
|
||||
}
|
||||
@ -81,7 +81,7 @@ export abstract class Body {
|
||||
*/
|
||||
arrayBuffer(): ArrayBuffer {
|
||||
if (this._body instanceof ArrayBuffer) {
|
||||
return <ArrayBuffer>this._body;
|
||||
return this._body;
|
||||
}
|
||||
|
||||
return stringToArrayBuffer(this.text());
|
||||
@ -92,7 +92,7 @@ export abstract class Body {
|
||||
*/
|
||||
blob(): Blob {
|
||||
if (this._body instanceof Blob) {
|
||||
return <Blob>this._body;
|
||||
return this._body;
|
||||
}
|
||||
|
||||
if (this._body instanceof ArrayBuffer) {
|
||||
|
@ -118,7 +118,7 @@ export class Http {
|
||||
if (typeof url === 'string') {
|
||||
responseObservable = httpRequest(
|
||||
this._backend,
|
||||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, <string>url)));
|
||||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)));
|
||||
} else if (url instanceof Request) {
|
||||
responseObservable = httpRequest(this._backend, url);
|
||||
} else {
|
||||
@ -215,8 +215,7 @@ export class Jsonp extends Http {
|
||||
request(url: string|Request, options?: RequestOptionsArgs): Observable<Response> {
|
||||
let responseObservable: any;
|
||||
if (typeof url === 'string') {
|
||||
url =
|
||||
new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, <string>url));
|
||||
url = new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url));
|
||||
}
|
||||
if (url instanceof Request) {
|
||||
if (url.method !== RequestMethod.Get) {
|
||||
|
Reference in New Issue
Block a user