Referer configured incorrectly in Android WebView

So, I have a webapp running through an Android WebView and I need to use it correctly document.referrer

in JavaScript in my web pages. I've tried the following:

webView.setWebViewClient(new MyWebViewClient());

private class MyWebViewClient extends WebViewClient {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("Referer", view.getUrl());
        view.loadUrl(url, headers);
        return false;
    }
}

      

But it didn't seem to go right. I set a breakpoint inside, checked the headers variable, and the url is correct, but the value for document.referrer

called from JavaScript on the next page does not match the one I set it to.

+3


source to share





All Articles