Is possible to change body content?
First of all, I deeply appreciate this very good project. I wonder If a changed request does not make any problem when I change some body content.
ex. override fun shouldInterceptRequest( view: WebView, webViewRequest: WebViewRequest ): WebResourceResponse? { webViewRequest.body = changedBodyString return super.shouldInterceptRequest(view, webViewRequest) }
I'm glad to hear!
This library does not actually send the request, it just inspects it. So changing the body has no effect. However, it wouldn't be difficult to implement that functionality: you have to copy the data from WebViewRequest to e.g. okhttp's Request, then send it, then return the response in a WebResourceResponse. Do you think it would be a good idea to include such a feature in this library itself?
Thanks for your good suggestions. And In my opinion about your ask... Yea. I think many people want such features. I could find many questions on google about how to change body content of WebView Request.
I agree, it seems like a useful feature. Would you like to make that contribution? I can help and review it:)
Hi,
is it possible to achieve the "changing response content/receiving the response" feature by adding some JS listeners to JAVASCRIPT_INTERCEPTION_CODE?
@MostafaAryan It's probably possible, but that doesn't seem like an easy/optimal way. Since, if everything works as expected, we have all the data in Kotlin, it's much simpler to execute the request in Kotlin, and then return the result to the Android framework, than modify the data in Javascript after passing it back from Kotlin.