diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java index c36bf256..4a892dc7 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java @@ -220,7 +220,7 @@ public class InterceptAjaxRequestJS { " data = new Uint8Array(result.data);" + " }" + " self.withCredentials = result.withCredentials;" + - " if (result.responseType != null) {" + + " if (result.responseType != null && self.isAsync) {" + " self.responseType = result.responseType;" + " };" + " for (var header in result.headers) {" + @@ -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);" + diff --git a/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift b/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift index b5d3a54f..be260499 100644 --- a/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift +++ b/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift @@ -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); diff --git a/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift b/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift index b5d3a54f..be260499 100644 --- a/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift +++ b/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/InterceptAjaxRequestJS.swift @@ -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);