Hi Mikhail,
thanks for your suggestion. Unfortunately it won't work for me. The "promise" is not the WebResourceResponse but the wrapped InputStream. WebResourceResponse is resolved immediately - AwWebResourceResponse is made from it, expecting headers and http code and mime type and all be ready.
On the other hand, InputStream poses as a promise indeed - not resolved until bubbled all the way through to native code async task RunShouldInterceptRequest.
So the first thing called on the WebResourceResponse reimplementation, immediately after returning shouldInterceptRequest, is getResponseHeaders. Which Mobilyzer does not reimplement in MyWebResourceResponse, so it supposedly returns null. It may work for Mobilyzer, but it won't work for generic web traffic interception. At the moment of getResponseHeaders call, i already need to know the decision of the other WebView JS code, and know the actual server response in case that JS code decides that it's ok. getData() could be deffered thanks to the nature of InputStream, but i need a full response, not just the body (which is what Mobilyzer code returns).
The only chance for me is to propagate the asynchronicity of RunShouldInterceptRequest task all the way through JNI. Put another way, i am trying to get on par with iOS NSURLProtocol, which is fully asynchronous traffic interceptor. So how insane is that, please? :-)
Cheers,
Pavel
Dne pondělí 8. února 2016 18:16:39 UTC+1 Mikhail Naganov napsal(a):