fix(http): return empty string if no body is present (#10668)
This commit is contained in:
parent
2d520ae7e7
commit
7cd4741fcb
|
@ -49,6 +49,10 @@ export abstract class Body {
|
|||
return String.fromCharCode.apply(null, new Uint16Array(<ArrayBuffer>this._body));
|
||||
}
|
||||
|
||||
if (this._body === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (isJsObject(this._body)) {
|
||||
return Json.stringify(this._body);
|
||||
}
|
||||
|
|
|
@ -77,5 +77,16 @@ export function main() {
|
|||
expect(req.detectContentType()).toEqual(ContentType.BLOB);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return empty string if no body is present', () => {
|
||||
const req = new Request(new RequestOptions({
|
||||
url: 'test',
|
||||
method: 'GET',
|
||||
body: null,
|
||||
headers: new Headers({'content-type': 'application/json'})
|
||||
}));
|
||||
|
||||
expect(req.text()).toEqual('');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue