New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 619832 link

Starred by 2 users

Issue metadata

Status: Archived
Owner: ----
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

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.
 
Components: Mobile>WebView

Comment 2 by boliu@chromium.org, 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?

Comment 3 by em...@vinodk.me, 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.

Comment 4 by boliu@chromium.org, 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.

Comment 5 by boliu@chromium.org, 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?
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?
Cc: gsennton@chromium.org boliu@chromium.org
Bo, any ideas after #6?
I could try to take a look at this when I'm back in London.

Comment 8 by boliu@chromium.org, Aug 29 2016

Labels: Needs-Feedback
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.
Project Member

Comment 9 by sheriffbot@chromium.org, Aug 30 2017

Status: Archived (was: Unconfirmed)
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
Status: Available (was: Archived)
Why reopen this? It sounds like we couldn't repro and never got a demo.

Comment 12 by boliu@chromium.org, Sep 11 2017

Status: Archived (was: Available)
err, didn't read my own comment in #8 XD

Sign in to add a comment