Page 1 of 1

How to Get PostData and ResponseData in OnBeforeResourceLoad or OnResourceResponse Event

Posted: Thu Aug 10, 2017 6:46 am
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?

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

Posted: Thu Aug 10, 2017 10:06 am
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

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

Posted: Thu Aug 10, 2017 5:44 pm
by salvadordf
Hi,

I'm really busy these days. I'll add a demo about that as soon as I can.

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

Posted: Fri Aug 11, 2017 2:47 am
by crystalxp
Ok,Thank you very much.

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

Posted: Sat Aug 12, 2017 2:58 pm
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.

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

Posted: Wed Aug 16, 2017 2:54 am
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.

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

Posted: Wed Aug 16, 2017 11:08 am
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.

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

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

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

Posted: Sat Jan 27, 2018 8:04 am
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 ?

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

Posted: Mon Jan 29, 2018 12:32 am
by yiqianyishi
Hi,
Is this problem solved?
Can you share a solution?
Thanks