I would like to intercept ajax call from WebView, add extra data to the url, and continue with the request as usual:
For example: change http://localhost:5000/doSomething to
http://localhost:5000/doSomething?secret=my_secret
and then pass the request for the web server.
I didn't succeeded doing that with shouldInterceptRequest
Related
How can I make a WebView request the CSS and javascript links when I load HTML externally into the WebView?
This question is similar to:
https://stackoverflow.com/questions/34608714/css-and-js-files-not-loading-in-android-webview
but we are loading everything from a server. In order to support SSL Pinning we override the
loadUrl(String url)
method (and will override the others) and handle the request with an HttpClient.execute call. When we receive the data back from the network, then we push it into the webview with
WebView.loadData(event.getContent(), event.getMimeType(), event.getEncoding());
How should we implement this design to retrieve data externally and then load it into the webview? The approach above shows the HTML fine but the CSS files are not loaded.
You don't. Use the loadDataWithBaseURL. Then the WebView will fire requests to load the css/js/png. The tricky part is you can override WebView.loadUrl for the initial request but then override WebViewClient.shouldInterceptRequest for each of the css/js/png requests. In there you can fire your network request and return the response as a stream (WebResourceResponse).
Is it possible to set the HTTP referer or HTTP header data generally in a WebView?
I know there is a method loadUrl(String url, Map<String, String> additionalHttpHeaders)
How to send a referer request in a url for a webView
But the headers are only sent for the given URL.
I need to set headers for every request that is sent via JavaScript from within the WebView.
I Have try to open the webapplication within mobile application..
Does somebody know a solution?
I am working with the web views in android, XMLHTTP requests are sending to the server from my application in the web view, how can i read the HTTP post request body
There are no WebViewClient/WebChromeClient callbacks for this (the closest is shouldInterceptRequest but that only gives you a URL). If the JavaScript is yours use addJavaScriptInterface to pass the request body to the Java code.
I am using WebView in Android. My ASP.NET Server set a cookie in WebView which is used to track user. Every thing works fine. Now I need to send an explicit HTTP POST request to server with the same cookie. Is it possible?
is there a way to get request and response objects from a webview?
for requests made from some webpage running in my webview, i want to intercept the full http request object(the headers, http method used, http body etc) and divert and send across that request into another channel.
For responses received from the webview, i want to do the same and get the object and its properties.
So far i have looked at the webviewClient android class which allows you to intercept url links executed by a webpage and intercept the resources it loads.
However, what i want to intercept, is any actual http requests the webpage makes. is this possible in Android webview?
thanks
That is not directly possible. You are welcome to write an HTTP proxy, then attempt to get WebView to work with that (e.g., see if it supports the http.proxyHost and http.proxyPort system properties).