mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Ignore request body for XHR GET requests.
Raises an error on Android. Caused by the Angular XHR backend sending an empty string.
This commit is contained in:
@@ -212,6 +212,14 @@ export var test_XMLHttpRequest_requestShouldBePossibleAfterAbort = function (don
|
||||
xhr.send(JSON.stringify({ MyVariableOne: "ValueOne", MyVariableTwo: "ValueTwo" }));
|
||||
};
|
||||
|
||||
export function test_ignore_zero_length_request_body(done) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "https://httpbin.org/get");
|
||||
|
||||
xhr.send('');
|
||||
done(null);
|
||||
}
|
||||
|
||||
export function test_raises_onload_Event(done) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.onload = () => {
|
||||
|
||||
@@ -72,7 +72,10 @@ export class XMLHttpRequest {
|
||||
this._status = null;
|
||||
|
||||
if (types.isDefined(this._options)) {
|
||||
if (types.isString(data)) {
|
||||
if (types.isString(data) && this._options.method !== 'GET') {
|
||||
//The Android Java HTTP lib throws an exception if we provide a
|
||||
//a request body for GET requests, so we avoid doing that.
|
||||
//Browser implementations silently ignore it as well.
|
||||
this._options.content = data;
|
||||
} else if (data instanceof FormData) {
|
||||
this._options.content = (<FormData>data).toString();
|
||||
|
||||
Reference in New Issue
Block a user