The data in JSON format was intercepted

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

The data in JSON format was intercepted

Postby jcij » Tue Oct 12, 2021 3:53 am

I have a problem. Load the web page in the MFC embedded CEF browser. The data in JSON format will be returned during the loading process of the web page, but I can't get the data of the returned message body through the code. I need to judge whether the web page is loaded successfully through the data of the message body。
jcij
Newbie
 
Posts: 8
Joined: Tue Oct 12, 2021 3:39 am

Re: The data in JSON format was intercepted

Postby pscyb » Wed Oct 13, 2021 9:54 pm

I have the same problem. My MFC program is embedded with CeF3. The version is 76.0.3809.132_ Windows 32 ,first loads a web page that I can't control. The user needs to login, and I need to grab the JSON data returned during the page loading XHR process, judge whether the user login successfully through some tags in the data, and then get the cookie, but I can only intercept the message header, not the specific data of the message body. What should I do to realize the above needs? Who can help answer it? Thank you very much!
pscyb
Newbie
 
Posts: 1
Joined: Wed Oct 13, 2021 9:45 pm

Re: The data in JSON format was intercepted

Postby jcij » Sun Oct 17, 2021 7:51 pm

I want to know whether this function can be realized.Thanks.
jcij
Newbie
 
Posts: 8
Joined: Tue Oct 12, 2021 3:39 am

Re: The data in JSON format was intercepted

Postby ndesktop » Mon Oct 18, 2021 2:23 am

I would try to implement client handler GetResourceResponseFilter (maybe also OnResourceLoadComplete - here you have browser, frame and URLRequestStatus to decide if is main or subframe, and response as well as the request and received content length).
With CefResourceResponseFilter you have
Code: Select all
Filter(void* data_in,
                      size_t data_in_size,
                      size_t& data_in_read,
                      void* data_out,
                      size_t data_out_size,
                      size_t& data_out_written)

from which you can set data_in_read to data_in and return RESPONSE_FILTER_NEED_MORE_DATA to allow filter to continue, and accumulate data passed in data_in + data_in_size into a buffer.
When OnResourceLoadComplete arrives (or whatever other end condition you have) you might check the buffer for the desired content, trigger your logic, and reset the buffer.

Note. I did not wrote such thing, I am just advancing an opinion here.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am


Return to CEF Discussion

Who is online

Users browsing this forum: Majestic-12 [Bot] and 20 guests