Android-AdvancedWebView icon indicating copy to clipboard operation
Android-AdvancedWebView copied to clipboard

goBack() is loading the same page, when the page is redirected

Open palkesh-jain opened this issue 6 years ago • 1 comments

When I check out an article on twitter, it is successfully opening the page after multiple redirects but the problem comes when I press the back button then it loads the last URL (that's the redirecting URL of the current page) and end up showing the current page again.

screenshot 2019-03-04 at 7 57 52 pm

Log scheme:

Org: <URL from webview.getOriginalUrl()> Url: <URL from webview.getUrl()>

palkesh-jain avatar Mar 04 '19 14:03 palkesh-jain

Thanks a lot for mentioning this!

The problem is that we override WebViewClient#shouldOverrideUrlLoading and always return false, intercepting the request and sending a new request via our custom version of WebView#loadUrl, as you can see here.

This is useful only if you have custom HTTP headers defined, as you can see here. But even then, not sure if we want those side effects.

We should probably replace

// route the request through the custom URL loading method
view.loadUrl(url);

// cancel the original request
return true;

with just

// pass through the original request
return false;

but that would break custom HTTP headers for non-manual, subsequent requests. But those are broken for POST requests, etc., anyway.

ocram avatar Mar 05 '19 16:03 ocram