Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a Referer on an android WebView in KitKat and up

KitKat got the new Chromium based WebView however now it no longer passes the Referer header through. I've always done the following (which always used to work but as of KitKat no longer does):

headers.put("Referer", referrer);
webView.loadUrl(someUrl, headers);

Debugging with Charles Proxy I can see that no Referer header is passed. If I rename the header to something like "Referrer" (with two r's) it goes through fine, although that's not a solution since the header is Referer with one r.

If anyone has a working solution for passing the Referer header in Android WebView's on KitKat and higher I'd appreciate any help!

like image 508
ToddH Avatar asked Nov 10 '22 02:11

ToddH


1 Answers

Same problem. I've found a great workaround. If Android version is 4.4.3 or 4.4.4, pass the header "Referer " (with final space). Works perfect!

like image 69
Josue Avatar answered Nov 14 '22 21:11

Josue