Page 1 of 1

Intercept XHR requests

Posted: Tue Sep 20, 2022 11:08 pm
by darkducke
Is it possible to intercept xhr requests made by the browser? I have a page that I access and after loading it makes some xhr requests and return some data in JSON, how do I get this JSON returned by this request?

thanks!

Re: Intercept XHR requests

Posted: Wed Sep 21, 2022 7:05 am
by salvadordf
Hi,

There's no easy way to get that body of that response in CEF but it's possible.

Try the ResponseFilterBrowser demo to know how to use a TCustomResponseFilter.

Read the code comments in the source code and the linked documents.

Re: Intercept XHR requests

Posted: Wed Sep 21, 2022 5:05 pm
by salvadordf
In general, if you need to intercept the contents of any text resource you can just replace the initial URL in AddressEdt.Text and then edit the IsMyResource function. Set the TempName variable with some unique part of the URL that you need to in intercept.

If the URL request is always the same you can also use the URLRequest demo to send the request manually.
Reading the response is much easier in this case.