fixed InterceptAjaxRequestJS Failed to set responseType property also on iOS and macOS, fixed shouldInterceptAjaxRequest javascript code when overriding XMLHttpRequest.open method parameters

This commit is contained in:
Lorenzo Pichilli 2023-12-06 18:05:18 +01:00
parent 5fb5e8afce
commit bfe5971d84
3 changed files with 17 additions and 8 deletions

View File

@ -233,10 +233,13 @@ public class InterceptAjaxRequestJS {
" }" +
" setRequestHeader.call(self, header, value);" +
" };" +
" if ((self._flutter_inappwebview_method != result.method && result.method != null) || (self._flutter_inappwebview_url != result.url && result.url != null)) {" +
" if ((self._flutter_inappwebview_method != result.method && result.method != null) ||" +
" (self._flutter_inappwebview_url != result.url && result.url != null) ||" +
" (self._flutter_inappwebview_isAsync != result.isAsync && result.isAsync != null) ||" +
" (self._flutter_inappwebview_user != result.user && result.user != null) ||" +
" (self._flutter_inappwebview_password != result.password && result.password != null)) {" +
" self.abort();" +
" self.open(result.method, result.url, result.isAsync, result.user, result.password);" +
" return;" +
" }" +
" }" +
" send.call(self, data);" +

View File

@ -219,7 +219,7 @@ let INTERCEPT_AJAX_REQUEST_JS_SOURCE = """
data = new Uint8Array(result.data);
}
self.withCredentials = result.withCredentials;
if (result.responseType != null) {
if (result.responseType != null && self.isAsync) {
self.responseType = result.responseType;
};
if (result.headers != null) {
@ -234,10 +234,13 @@ let INTERCEPT_AJAX_REQUEST_JS_SOURCE = """
setRequestHeader.call(self, header, value);
};
}
if ((self._flutter_inappwebview_method != result.method && result.method != null) || (self._flutter_inappwebview_url != result.url && result.url != null)) {
if ((self._flutter_inappwebview_method != result.method && result.method != null) ||
(self._flutter_inappwebview_url != result.url && result.url != null) ||
(self._flutter_inappwebview_isAsync != result.isAsync && result.isAsync != null) ||
(self._flutter_inappwebview_user != result.user && result.user != null) ||
(self._flutter_inappwebview_password != result.password && result.password != null)) {
self.abort();
self.open(result.method, result.url, result.isAsync, result.user, result.password);
return;
}
}
send.call(self, data);

View File

@ -219,7 +219,7 @@ let INTERCEPT_AJAX_REQUEST_JS_SOURCE = """
data = new Uint8Array(result.data);
}
self.withCredentials = result.withCredentials;
if (result.responseType != null) {
if (result.responseType != null && self.isAsync) {
self.responseType = result.responseType;
};
if (result.headers != null) {
@ -234,10 +234,13 @@ let INTERCEPT_AJAX_REQUEST_JS_SOURCE = """
setRequestHeader.call(self, header, value);
};
}
if ((self._flutter_inappwebview_method != result.method && result.method != null) || (self._flutter_inappwebview_url != result.url && result.url != null)) {
if ((self._flutter_inappwebview_method != result.method && result.method != null) ||
(self._flutter_inappwebview_url != result.url && result.url != null) ||
(self._flutter_inappwebview_isAsync != result.isAsync && result.isAsync != null) ||
(self._flutter_inappwebview_user != result.user && result.user != null) ||
(self._flutter_inappwebview_password != result.password && result.password != null)) {
self.abort();
self.open(result.method, result.url, result.isAsync, result.user, result.password);
return;
}
}
send.call(self, data);