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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post Reply
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by crystalxp »

Hi,salvadordf.
Here are some webpage using ajax to update data after pageloaded...
the update url like this : http://xxx/Standard?jsoncallback=jQuery ... 2097411178
and I want to get info from those url....

I can trace it in OnBeforeResourceLoad or OnResourceResponse Event..
but I don't know How to get Info( like PostData and ResponseData ) In those events.
I find there are lack of demo to show how to deal with ICefRequest , ICefResponse...
Can you help me,thanks?
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by crystalxp »

now I have solved how to get postdata by using following code:
tmpEle := tmpList.Items[0] as ICefPostDataElement;
PostData:= AllocMem(tmpEle.GetBytesCount);
tmpEle.GetBytes(tmpEle.GetBytesCount, PostData);
mmolog.Lines.Add(PAnsiChar(PostData));
FreeMemory(PostData);

but still have no idea on how to getResponseData in OnResourceResponse Event
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by salvadordf »

Hi,

I'm really busy these days. I'll add a demo about that as soon as I can.
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by crystalxp »

Ok,Thank you very much.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by salvadordf »

Hi,

Download the latest CEF4Delphi version. The new MiniBrowser demo has some simple code that stores the last response status using the TChromium.OnResourceResponse.

These are the code comments about that event :

Code: Select all

  ///
  // Called on the IO thread when a resource response is received. To allow the
  // resource to load normally return false (0). To redirect or retry the
  // resource modify |request| (url, headers or post body) and return true (1).
  // The |response| object cannot be modified in this callback.
  ///
I'm not sure if the response data you're looking for can be obtained with the ICefResponse.GetHeaderMap procedure inside the TChromium.OnResourceResponse event.

If that's the case, you have the code to read the header map in the TChromium.doOnBeforeResourceLoad procedure in the uCEFChromium.pas file.
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by crystalxp »

Thanks,but this is not useful for me .... What really I wanted is Get ResponseDate in ResponseContent, not the response header or any others.
for example in OnResourceResponse, the server will return a ajax data like JQquery1983437373838282_123583777(xxxxxx)...and I want to get it ...


as these datas are retrived after the page loadend...so it can be only traced in OnResourceResponse..... I have aready search the response: ICefResponse object ...but can only get header or status....it can not get content body...what is really I wanted.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by salvadordf »

Hi,

I haven't tested it but maybe this is what you're looking for...
http://www.magpcss.org/ceforum/viewtopi ... =6&t=10794

Take a look at the CustomResourceBrowser demo.
crystalxp
Posts: 39
Joined: Tue Jul 04, 2017 8:23 am

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by crystalxp »

ok,i will researh futher, thanks again.
mike2k
Posts: 22
Joined: Wed Jan 24, 2018 2:56 pm

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by mike2k »

crystalxp wrote: Sat Aug 19, 2017 12:31 am ok,i will researh futher, thanks again.
Hi crystalxp,

Have you managed to get the responsedata ?
yiqianyishi
Posts: 18
Joined: Sun Jan 07, 2018 1:08 am

Re: How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Post by yiqianyishi »

Hi,
Is this problem solved?
Can you share a solution?
Thanks
Post Reply