如何在WebView中更新请求标头 [英] How to update request header in WebView
本文介绍了如何在WebView中更新请求标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从android Webview访问URL.在加载我通过chrome检查的URL时,一个标头值为null(请参见下图).
I'm trying to access a URL from android WebView. While loading the URL i inspected through chrome that one header value is null (See the following image).
我的问题是,我想更新Origin值.我该怎么办?
My question is, i want to update the Origin value. How can i do it?
注意::如果Origin仅具有null值,我必须以其他方式更新,否则我必须按原样加载
Note: If Origin has null value only i've to update other wise i've to load as it is
推荐答案
webView = (WebView) findViewById(R.id.webView);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
progressBar.setProgress(progress);
if (progress == 100) {
progressBar.setVisibility(View.GONE);
}
}
});
HashMap<String, String> headers=new HashMap<>();
webView.loadUrl("https://stackoverflow.com",headers);
这篇关于如何在WebView中更新请求标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文