I want to add my header to each request in webview but I dont want recreate the request using OkHttp or DefaultHttpClient since WebResourceRequest from shouldInterceptRequest does not return the request body so my POST requests wont have value when i send it.
I tried adding my header inside shouldInterceptRequest but i doesnt work properly seems its not adding on each request.
override fun shouldInterceptRequest(view: WebView?, request: WebResourceRequest?): WebResourceResponse? {
request?.requestHeaders?.clear()
request?.requestHeaders?.apply {
put("header", "value")
}
return super.shouldInterceptRequest(view, request)
}