Open rikucherry1993 opened 2 months ago
👋 @rikucherry1993
NOTE: This comment is auto-generated.
Are you sure you have already searched for the same problem?
Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!
If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.
In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE]
or ios WKWebView [MY ERROR HERE]
keywords.
Following these steps can save you, me, and other people a lot of time, thanks!
Environment
Device information:
Description
This is more of a question regarding the implementation.
When toggle on the flag
useShouldOverrideUrlLoading
inInAppWebViewSettings
, on the Android side implementation of the plugin it goes to: (InAppWebViewClientCompat::shouldOverrideUrlLoading
) https://github.com/pichillilorenzo/flutter_inappwebview/blob/751a104716b2c5158b5cad58347430d01965f00d/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java#L76-L101According to the above logic, as long as the
request.isForMainFrame()
is trueshouldOverrideUrlLoading
always returns true, which causes the webView stops loading current url. This is regardless of whether flutter side returnsALLOW
orCANCEL
.Then in the case that flutter returns ALLOW, the WebViewClient called
webview.loadUrl()
to manually load same url: https://github.com/pichillilorenzo/flutter_inappwebview/blob/v6.0.0/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java#L117-L128 This actually overwrites the original request with a new request, which no longer contains the original headers information.But this is agianst the [Android documentation](https://developer.android.com/reference/android/webkit/WebViewClient?_gl=1*f2qg76*_up*MQ..*_ga*OTAyMzAzMi4xNzIzMDAwOTkx*_ga_6HH9YJMN9M*MTcyMzAwMDk5MS4xLjAuMTcyMzAwMDk5Ni4wLjAuMA..#shouldOverrideUrlLoading(android.webkit.WebView,%20android.webkit.WebResourceRequest) :
if it's ALLOW, shouldn't it just let the
shouldOverrideUrlLoading
method returns false so the webview can continue to load same url? Why it returns true then reload the url itself?As a result the request header is always missing as long as it went through the shouldOverrideUrlLoading.
Expected behavior:
Current behavior:
Steps to reproduce
Images
Stacktrace/Logcat