Webview: Not keeping custom headers while going back browser history
Reported by
em...@vinodk.me,
Jun 14 2016
|
||||||
Issue description
Steps to reproduce the problem:
1. Implement webview in android app
2. navigate to some links (send custom headers)
3. navigate back by webview's goBack() method
What is the expected behavior?
Should keep the custom http headers sent with requests while navigating back from History back.
What went wrong?
Loosing the custom http headers sent with requsts when executing same request by going back by goback() function.
Did this work before? No
Chrome version: 51.0.2704.81 Channel: stable
OS Version: 10.0
Flash Version:
I have implemented the webview in my app and passed some custom headers to each request like this..
public class mywebviewextends BaseActivity implements OnClickListener {
...
final Map<String, String> map = new HashMap<String, String>();
...
@Override
public void onCreate(Bundle savedInstanceState) {
map.put("my_custom_var", "My Custom Value");
mywebview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url, map);
return true;
}
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && wvBrowseCategory.canGoBack()) {
mywebview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
Since there's no option to send 'map' (mapping of custom headers) to 'goBack()' method, custom headers are not kept with request.
,
Jun 14 2016
> Since there's no option to send 'map' (mapping of custom headers) to 'goBack()' method, custom headers are not kept with request. Webview internally stores the headers on the initial load, and should reuse them if you go back to a page. Are you complaining about a bug here, or you want to add extra headers parameter to goBack?
,
Jun 15 2016
I am passing some custom headers with requests which are being sent through but they are lost when we go back goBack(), so I want to keep my custom headers even with calling go Back(). So this seems a bug to me.
,
Jun 16 2016
Hmm, we don't stash the extra headers NavigationController anymore since https://codereview.chromium.org/99683006, 3 years ago :o That probably broke this.
,
Jun 16 2016
Well, looking at the code, the map in AwResourceContext just keeps growing and growing after each navigation. Bad for memory, but actually good for this bug. So why isn't the back navigation also consulting AwResourceContext for extra headers?
,
Jul 6 2016
It looks like we do add the extra headers - we do call AwResourceDispatcherHostDelegate::AddExtraHeadersIfNeeded and successfully add the extra headers to the request https://cs.chromium.org/chromium/src/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc?l=441 might we be resetting the headers later?
,
Aug 22 2016
Bo, any ideas after #6? I could try to take a look at this when I'm back in London.
,
Aug 29 2016
I just tested this. custom headers of the original loadUrl *are* applied to the request for the back navigation. So going to need an apk demonstrating the problem.
,
Aug 30 2017
Issue has not been modified or commented on in the last 365 days, please re-open or file a new bug if this is still an issue. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Sep 1 2017
,
Sep 5 2017
Why reopen this? It sounds like we couldn't repro and never got a demo.
,
Sep 11 2017
err, didn't read my own comment in #8 XD |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by rsgav...@chromium.org
, Jun 14 2016