Clean up X-Requested-With change

This only really affects the initial request, subsequent requests may still use the package name.
This commit is contained in:
arkon
2020-08-22 12:49:00 -04:00
parent 3f1355c413
commit 9920ff617b
3 changed files with 8 additions and 6 deletions

View File

@@ -70,13 +70,14 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
if (bundle == null) {
val url = intent.extras!!.getString(URL_KEY) ?: return
var headers = emptyMap<String, String>()
var headers = mutableMapOf<String, String>()
val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource
if (source != null) {
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap()
binding.webview.settings.userAgentString = source.headers["User-Agent"]
}
headers["X-Requested-With"] = WebViewUtil.REQUESTED_WITH
binding.webview.setDefaultSettings()
@@ -100,9 +101,7 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
binding.webview.webViewClient = object : WebViewClientCompat() {
override fun shouldOverrideUrlCompat(view: WebView, url: String): Boolean {
val android_browser: MutableMap<String, String> = HashMap()
android_browser["X-Requested-With"] = "com.android.browser"
view.loadUrl(url,android_browser)
view.loadUrl(url, headers)
return true
}