fixed issue with headers in javascript code for intercepting ajax requests
This commit is contained in:
parent
a11936c188
commit
fed2da63ba
|
@ -15,23 +15,12 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/example/test_assets/in_app_webview_on_console_message_test.html" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/example/test_assets/in_app_webview_on_download_start_test.html" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/example/test_assets/in_app_webview_on_target_blank_test.html" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/example/test_driver/in_app_webview_on_console_message_test.dart" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/example/test_driver/in_app_webview_on_download_start_test.dart" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/example/test_driver/in_app_webview_on_target_blank_test.dart" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/example/test_driver/in_app_webview_should_override_url_loading_test.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/assets/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/example/assets/index.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/ios/Runner/Info.plist" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner/Info.plist" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/lib/webview_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/webview_example.screen.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/test_driver/app_test.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/test_driver/app_test.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/test_driver/main_test.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/test_driver/main_test.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/in_app_webview.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_webview.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/types.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/types.dart" afterDir="false" />
|
||||
|
@ -69,7 +58,7 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/test_driver/main_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<state relative-caret-position="-62">
|
||||
<caret line="31" column="73" selection-start-line="31" selection-start-column="73" selection-end-line="31" selection-end-column="73" />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -78,8 +67,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="397">
|
||||
<caret line="178" column="52" selection-start-line="178" selection-start-column="52" selection-end-line="178" selection-end-column="52" />
|
||||
<state relative-caret-position="180">
|
||||
<caret line="12" column="25" selection-start-line="12" selection-start-column="6" selection-end-line="12" selection-end-column="25" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -88,10 +77,19 @@
|
|||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="251">
|
||||
<caret line="51" column="33" selection-start-line="51" selection-start-column="33" selection-end-line="51" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="183">
|
||||
<caret line="745" column="20" lean-forward="true" selection-start-line="745" selection-start-column="20" selection-end-line="745" selection-end-column="20" />
|
||||
<state relative-caret-position="-303">
|
||||
<caret line="278" column="24" selection-start-line="278" selection-start-column="13" selection-end-line="278" selection-end-column="24" />
|
||||
<folding>
|
||||
<element signature="e#0#17#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -99,11 +97,20 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1146">
|
||||
<caret line="1155" column="24" selection-start-line="1155" selection-start-column="6" selection-end-line="1155" selection-end-column="24" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="870">
|
||||
<caret line="58" column="7" selection-start-line="58" selection-start-column="7" selection-end-line="58" selection-end-column="7" />
|
||||
<state relative-caret-position="150">
|
||||
<caret line="10" column="49" selection-start-line="10" selection-start-column="49" selection-end-line="10" selection-end-column="49" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -120,11 +127,6 @@
|
|||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>IosSafariOptionsDismissButtonStyle</find>
|
||||
<find>method</find>
|
||||
<find>AjaxRequestEvent</find>
|
||||
<find>withCredentials</find>
|
||||
<find>current</find>
|
||||
<find>FetchRequest</find>
|
||||
<find>my-special-custom-scheme</find>
|
||||
<find>should</find>
|
||||
|
@ -150,6 +152,11 @@
|
|||
<find>getHtml</find>
|
||||
<find>loadUrl</find>
|
||||
<find>evaluateJavascript</find>
|
||||
<find>isAsync</find>
|
||||
<find>"headers": headers</find>
|
||||
<find>shouldIn</find>
|
||||
<find>onZaboHandlerCallback</find>
|
||||
<find>AndroidView</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>activity.getPreferences(0)</replace>
|
||||
|
@ -175,7 +182,6 @@
|
|||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/flutter_inappbrowser_tests/lib/util_test.dart" />
|
||||
<option value="$PROJECT_DIR$/flutter_inappbrowser_tests/android/app/src/main/AndroidManifest.xml" />
|
||||
<option value="$PROJECT_DIR$/flutter_inappbrowser_tests/assets/in_app_webview_initial_file_test.html" />
|
||||
<option value="$PROJECT_DIR$/flutter_inappbrowser_tests/assets/in_app_webview_on_load_resource_test.html" />
|
||||
|
@ -215,7 +221,6 @@
|
|||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<option value="$PROJECT_DIR$/example/lib/webview_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/example/test_assets/in_app_webview_on_console_message_test.html" />
|
||||
<option value="$PROJECT_DIR$/lib/src/types.dart" />
|
||||
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_on_console_message_test.dart" />
|
||||
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_on_download_start_test.dart" />
|
||||
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_on_target_blank_test.dart" />
|
||||
|
@ -224,8 +229,10 @@
|
|||
<option value="$PROJECT_DIR$/example/test_assets/in_app_webview_on_download_start_test.html" />
|
||||
<option value="$PROJECT_DIR$/example/test_driver/app_test.dart" />
|
||||
<option value="$PROJECT_DIR$/example/assets/index.html" />
|
||||
<option value="$PROJECT_DIR$/example/lib/inline_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/types.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/inline_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/main.dart" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -494,7 +501,7 @@
|
|||
<window_info id="Resources Explorer" order="8" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" weight="0.32642487" />
|
||||
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49574015" visible="true" weight="0.4549223" />
|
||||
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49574015" weight="0.4746114" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.34196892" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
|
@ -506,7 +513,7 @@
|
|||
<window_info anchor="bottom" id="Messages" order="11" weight="0.3896373" />
|
||||
<window_info anchor="bottom" id="Dependency Viewer" order="12" weight="0.32800853" />
|
||||
<window_info anchor="bottom" id="Logcat" order="13" weight="0.32953367" />
|
||||
<window_info anchor="bottom" id="Dart Analysis" order="14" sideWeight="0.4968051" weight="0.3253886" />
|
||||
<window_info active="true" anchor="bottom" id="Dart Analysis" order="14" sideWeight="0.4968051" visible="true" weight="0.3253886" />
|
||||
<window_info anchor="bottom" id="Flutter Performance" order="15" sideWeight="0.5042598" side_tool="true" weight="0.5160622" />
|
||||
<window_info anchor="bottom" id="Build" order="16" />
|
||||
<window_info anchor="bottom" id="Thumbnails" order="17" weight="0.32953367" />
|
||||
|
@ -533,7 +540,6 @@
|
|||
</ignored-roots>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/flutter_inappbrowser_tests/assets/in_app_webview_ajax_test.html" />
|
||||
<entry file="file://$PROJECT_DIR$/test_driver/custom_widget_test.dart" />
|
||||
<entry file="file://$PROJECT_DIR$/test_driver/main_test.dart" />
|
||||
<entry file="file://$PROJECT_DIR$/test_driver/app.dart" />
|
||||
|
@ -742,13 +748,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="346">
|
||||
<caret line="45" column="13" lean-forward="true" selection-start-line="45" selection-start-column="13" selection-end-line="45" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/test_assets/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="327">
|
||||
|
@ -791,13 +790,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="870">
|
||||
<caret line="58" column="7" selection-start-line="58" selection-start-column="7" selection-end-line="58" selection-end-column="7" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/test_driver/app_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="490">
|
||||
|
@ -808,33 +800,54 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/test_driver/main_test.dart">
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<caret line="31" column="73" selection-start-line="31" selection-start-column="73" selection-end-line="31" selection-end-column="73" />
|
||||
<state relative-caret-position="150">
|
||||
<caret line="10" column="49" selection-start-line="10" selection-start-column="49" selection-end-line="10" selection-end-column="49" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1146">
|
||||
<caret line="1155" column="24" selection-start-line="1155" selection-start-column="6" selection-end-line="1155" selection-end-column="24" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="397">
|
||||
<caret line="178" column="52" selection-start-line="178" selection-start-column="52" selection-end-line="178" selection-end-column="52" />
|
||||
<state relative-caret-position="180">
|
||||
<caret line="12" column="25" selection-start-line="12" selection-start-column="6" selection-end-line="12" selection-end-column="25" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/test_driver/main_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-62">
|
||||
<caret line="31" column="73" selection-start-line="31" selection-start-column="73" selection-end-line="31" selection-end-column="73" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="183">
|
||||
<caret line="745" column="20" lean-forward="true" selection-start-line="745" selection-start-column="20" selection-end-line="745" selection-end-column="20" />
|
||||
<state relative-caret-position="-303">
|
||||
<caret line="278" column="24" selection-start-line="278" selection-start-column="13" selection-end-line="278" selection-end-column="24" />
|
||||
<folding>
|
||||
<element signature="e#0#17#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="251">
|
||||
<caret line="51" column="33" selection-start-line="51" selection-start-column="33" selection-end-line="51" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
|
|
|
@ -146,10 +146,12 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
" this._flutter_inappbrowser_isAsync = isAsync;" +
|
||||
" this._flutter_inappbrowser_user = user;" +
|
||||
" this._flutter_inappbrowser_password = password;" +
|
||||
" this._flutter_inappbrowser_request_headers = {};" +
|
||||
" open.call(this, method, url, isAsync, user, password);" +
|
||||
" };" +
|
||||
" ajax.prototype.setRequestHeader = function(header, value) {" +
|
||||
" this._flutter_inappbrowser_request_headers[header] = value;" +
|
||||
" setRequestHeader.call(this, header, value);" +
|
||||
" };" +
|
||||
" function handleEvent(e) {" +
|
||||
" var self = this;" +
|
||||
|
@ -290,10 +292,12 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
" };" +
|
||||
" for (var header in result.headers) {" +
|
||||
" var value = result.headers[header];" +
|
||||
" self._flutter_inappbrowser_request_headers[header] = value;" +
|
||||
" };" +
|
||||
" for (var header in self._flutter_inappbrowser_request_headers) {" +
|
||||
" var value = self._flutter_inappbrowser_request_headers[header];" +
|
||||
" var flutter_inappbrowser_value = self._flutter_inappbrowser_request_headers[header];" +
|
||||
" if (flutter_inappbrowser_value == null) {" +
|
||||
" self._flutter_inappbrowser_request_headers[header] = value;" +
|
||||
" } else {" +
|
||||
" self._flutter_inappbrowser_request_headers[header] += ', ' + value;" +
|
||||
" }" +
|
||||
" setRequestHeader.call(self, header, value);" +
|
||||
" };" +
|
||||
" if ((self._flutter_inappbrowser_method != result.method && result.method != null) || (self._flutter_inappbrowser_url != result.url && result.url != null)) {" +
|
||||
|
|
|
@ -39,7 +39,7 @@ public class JavaScriptBridgeInterface {
|
|||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void _callHandler(String handlerName, final String _callHandlerID, String args) {
|
||||
public void _callHandler(final String handlerName, final String _callHandlerID, String args) {
|
||||
final Map<String, Object> obj = new HashMap<>();
|
||||
if (inAppBrowserActivity != null)
|
||||
obj.put("uuid", inAppBrowserActivity.uuid);
|
||||
|
@ -62,10 +62,10 @@ public class JavaScriptBridgeInterface {
|
|||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
webView.evaluateJavascript("window." + name + "[" + _callHandlerID + "](" + json + "); delete window." + name + "[" + _callHandlerID + "];", (ValueCallback<String>) null);
|
||||
webView.evaluateJavascript("if(window." + name + "[" + _callHandlerID + "] != null) {window." + name + "[" + _callHandlerID + "](" + json + "); delete window." + name + "[" + _callHandlerID + "];}", (ValueCallback<String>) null);
|
||||
}
|
||||
else {
|
||||
webView.loadUrl("javascript:window." + name + "[" + _callHandlerID + "](" + json + "); delete window." + name + "[" + _callHandlerID + "];");
|
||||
webView.loadUrl("javascript:if(window." + name + "[" + _callHandlerID + "] != null) {window." + name + "[" + _callHandlerID + "](" + json + "); delete window." + name + "[" + _callHandlerID + "];}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSLocationAlwaysUsageDescription</key>
|
||||
<key>NSLocationAlwaysUsageDescription</key>
|
||||
<string>Need location</string>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>Need location</string>
|
||||
|
|
|
@ -450,4 +450,4 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
|
|||
: await getApplicationDocumentsDirectory();
|
||||
return directory.path;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -296,10 +296,12 @@ let interceptAjaxRequestsJS = """
|
|||
this._flutter_inappbrowser_isAsync = isAsync;
|
||||
this._flutter_inappbrowser_user = user;
|
||||
this._flutter_inappbrowser_password = password;
|
||||
this._flutter_inappbrowser_request_headers = {};
|
||||
open.call(this, method, url, isAsync, user, password);
|
||||
};
|
||||
ajax.prototype.setRequestHeader = function(header, value) {
|
||||
this._flutter_inappbrowser_request_headers[header] = value;
|
||||
setRequestHeader.call(this, header, value);
|
||||
};
|
||||
function handleEvent(e) {
|
||||
var self = this;
|
||||
|
@ -440,10 +442,12 @@ let interceptAjaxRequestsJS = """
|
|||
};
|
||||
for (var header in result.headers) {
|
||||
var value = result.headers[header];
|
||||
self._flutter_inappbrowser_request_headers[header] = value;
|
||||
};
|
||||
for (var header in self._flutter_inappbrowser_request_headers) {
|
||||
var value = self._flutter_inappbrowser_request_headers[header];
|
||||
var flutter_inappbrowser_value = self._flutter_inappbrowser_request_headers[header];
|
||||
if (flutter_inappbrowser_value == null) {
|
||||
self._flutter_inappbrowser_request_headers[header] = value;
|
||||
} else {
|
||||
self._flutter_inappbrowser_request_headers[header] += ', ' + value;
|
||||
}
|
||||
setRequestHeader.call(self, header, value);
|
||||
};
|
||||
if ((self._flutter_inappbrowser_method != result.method && result.method != null) || (self._flutter_inappbrowser_url != result.url && result.url != null)) {
|
||||
|
@ -2021,7 +2025,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
|
|||
if let r = result {
|
||||
json = r as! String
|
||||
}
|
||||
self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)](\(json)); delete window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)];", completionHandler: nil)
|
||||
self.evaluateJavaScript("if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)](\(json)); delete window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)];}", completionHandler: nil)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -591,7 +591,7 @@ class InAppWebViewController {
|
|||
String user = argMap["user"];
|
||||
String password = argMap["password"];
|
||||
bool withCredentials = argMap["withCredentials"];
|
||||
Map<dynamic, dynamic> headers = argMap["headers"];
|
||||
AjaxRequestHeaders headers = AjaxRequestHeaders(argMap["headers"]);
|
||||
String responseType = argMap["responseType"];
|
||||
|
||||
var request = new AjaxRequest(data: data, method: method, url: url, isAsync: isAsync, user: user, password: password, withCredentials: withCredentials, headers: headers, responseType: responseType);
|
||||
|
@ -610,7 +610,7 @@ class InAppWebViewController {
|
|||
String user = argMap["user"];
|
||||
String password = argMap["password"];
|
||||
bool withCredentials = argMap["withCredentials"];
|
||||
Map<dynamic, dynamic> headers = argMap["headers"];
|
||||
AjaxRequestHeaders headers = AjaxRequestHeaders(argMap["headers"]);
|
||||
int readyState = argMap["readyState"];
|
||||
int status = argMap["status"];
|
||||
String responseURL = argMap["responseURL"];
|
||||
|
@ -639,7 +639,7 @@ class InAppWebViewController {
|
|||
String user = argMap["user"];
|
||||
String password = argMap["password"];
|
||||
bool withCredentials = argMap["withCredentials"];
|
||||
Map<dynamic, dynamic> headers = argMap["headers"];
|
||||
AjaxRequestHeaders headers = AjaxRequestHeaders(argMap["headers"]);
|
||||
int readyState = argMap["readyState"];
|
||||
int status = argMap["status"];
|
||||
String responseURL = argMap["responseURL"];
|
||||
|
|
|
@ -1064,6 +1064,31 @@ class AjaxRequestReadyState {
|
|||
int get hashCode => _value.hashCode;
|
||||
}
|
||||
|
||||
///AjaxRequestHeaders class represents the HTTP headers of an [AjaxRequest].
|
||||
class AjaxRequestHeaders {
|
||||
Map<dynamic, dynamic> _headers;
|
||||
Map<String, dynamic> _newHeaders = {};
|
||||
|
||||
AjaxRequestHeaders(this._headers);
|
||||
|
||||
///Gets the HTTP headers of the [AjaxRequest].
|
||||
Map<dynamic, dynamic> getHeaders() {
|
||||
return this._headers;
|
||||
}
|
||||
|
||||
///Sets/updates an HTTP header of the [AjaxRequest]. If there is already an existing [header] with the same name, the values are merged into one single request header.
|
||||
///For security reasons, some headers can only be controlled by the user agent.
|
||||
///These headers include the [forbidden header names](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name)
|
||||
///and [forbidden response header names](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_response_header_name).
|
||||
void setRequestHeader(String header, String value) {
|
||||
_newHeaders[header] = value;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return _newHeaders;
|
||||
}
|
||||
}
|
||||
|
||||
///AjaxRequest class represents a JavaScript [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) object.
|
||||
class AjaxRequest {
|
||||
///Data passed as a parameter to the `XMLHttpRequest.send()` method.
|
||||
|
@ -1084,7 +1109,7 @@ class AjaxRequest {
|
|||
///In addition, this flag is also used to indicate when cookies are to be ignored in the response. The default is false.
|
||||
bool withCredentials;
|
||||
///The HTTP request headers.
|
||||
Map<dynamic, dynamic> headers;
|
||||
AjaxRequestHeaders headers;
|
||||
///The state of the `XMLHttpRequest` request.
|
||||
AjaxRequestReadyState readyState;
|
||||
///The numerical HTTP [status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) of the `XMLHttpRequest`'s response.
|
||||
|
@ -1128,7 +1153,7 @@ class AjaxRequest {
|
|||
"user": user,
|
||||
"password": password,
|
||||
"withCredentials": withCredentials,
|
||||
"headers": headers,
|
||||
"headers": headers?.toMap(),
|
||||
"readyState": readyState?.toValue(),
|
||||
"status": status,
|
||||
"responseURL": responseURL,
|
||||
|
|
Loading…
Reference in New Issue