Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Intercept XHR requests

Post Reply
darkducke
Posts: 21
Joined: Thu Feb 15, 2018 4:29 pm

Intercept XHR requests

Post 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!
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Intercept XHR requests

Post 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.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Intercept XHR requests

Post 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.
Post Reply