Android intercept the response body and headers from a WebView? - android

I need to intercept the responses coming back from the response and redirects of a webview as it's loading?
I need to read the headers during the redirect, and I need to read cookies coming back.
Is this possible? Looking at some samples on stackoverflow, most solutions use shouldOverrideUrlLoading but that only gives you access to the url, and not the full response

Related

How to read body of a POST request into Android WebView

I have to submit a form to an external URL, that provides into my WebView a series of interaction with the user.
At the end of this process this external service does a redirect to my another URL (that is fake) through a POST call, sending some data that I need to show at the user.
I tried to catch this POST request into the method shouldInterceptRequest, because I have to read data before the load of my fake url starts, but the methods that I can use on a WebResourceRequest object are useless. There is nothing to read the body of this request.
There is another way to catch my data? Any suggestions?
(I already tried the writeinterception project library, but it doesn't work.)
Thanks a lot in advance.

Receive POST information from callback, Android WebView

My scenario is this: we point the user to a form where they fill in the data (3DSecure) and then POST, the website then POSTS the response to a callback URL - this response is what I want to capture. WebView.shouldInterceptRequest() can get the headers but not the content (Why, Google?). I tried this link and it can get the POST data that the user sends. Is there any way to use Javascript to catch the POST data being received to a callback of my choosing?
I saw this post from 5 years ago and the man resorted to POSTing the response back to a server and then getting the contents from the phone. This is far from ideal. Surely there's a newer solution?
shouldInterceptRequest() mentions that a response contains the "response information or null if the WebView should load the resource itself", how do I get it so that the WebView shouldn't load the resource itself? The source code seems to return null always.
I used this gentleman's library: https://github.com/LivotovLabs/3DSView
If one was looking to do this with something other than 3DSecure they could use it as a template.

Android WebView loadUrl after postUrl

I have a problem using loadUrl after postUrl.
First I use postUrl to login to a website and after that I want to load another page from the same website with loadUrl. But after using loadUrl Im asked again to login.
Probably you need to handle cookie with WebView.
You need to store the COOKIE returned by the POST request (i.e., the login request). Then, whenever you send a GET request, you need to pass along the cookie so the sever knows you've already logged in.

Android-the method loadUrl() in webView sends POST or GET request?

i'm working with webview recently and i found 2 methods to load an URL in webView.
For postUrl() the doc said clearly it sends a POST request, but it didn't say anything about loadUrl().
can anybody tell me anything about it?

Android get request and response objects from webview

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).

Categories

Resources