retrieve response body in thread

Post Reply
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

retrieve response body in thread

Post by X11 » Thu Jan 16, 2020 1:50 pm

Hi.
Sory for my english :oops:

I am studying an demo example "ResponseFilterBrowser".
Example uses windows messaging api (Winapi.Messages).
But i use Tchromium in windows less mode in a separate thread without windows.
How can i retrieve response body in thread?

Thanx.
You do not have the required permissions to view the files attached to this post.

User avatar
salvadordf
Posts: 2068
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: retrieve response body in thread

Post by salvadordf » Thu Jan 16, 2020 2:14 pm

Hi,

The same way you do with a normal browser.

TChromium events will be executed in CEF threads and you will have to store the body contents in a variable protected by a critical section.
After that, send a message to the thread that will handle the body contents with PostThreadMessage :
https://stackoverflow.com/questions/13931782/messageloop-within-thread

I've never used it but some people recommend OmniThreadLibrary to simplify thread handling :
https://otl.17slon.com/

X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

Re: retrieve response body in thread

Post by X11 » Fri Jan 17, 2020 6:22 am

But is there no other way, without windows messaging api (Winapi.Messages)?

X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

Re: retrieve response body in thread

Post by X11 » Fri Jan 17, 2020 9:36 am

Can I use TCEFUrlRequestClientComponent in thread without Winapi.Messages?

User avatar
salvadordf
Posts: 2068
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: retrieve response body in thread

Post by salvadordf » Fri Jan 17, 2020 10:00 am

I've never tried this with that component but in theory you can set GlobalCEFApp.MultiThreadedMessageLoop to false, GlobalCEFApp.ExternalMessagePump to true and use the GlobalCEFWorkScheduler.

With that configuration the browser process message loop runs in the same thread.

The ExternalPumpBrowser demo has all the code you need to use the GlobalCEFWorkScheduler but I'm not sure it will work with TCEFUrlRequestClientComponent.

X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

Re: retrieve response body in thread

Post by X11 » Fri Jan 17, 2020 2:16 pm

It would be very nice if you added one more parameter to the OnResourceResponse Event - ResponseBody :roll:

User avatar
salvadordf
Posts: 2068
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: retrieve response body in thread

Post by salvadordf » Fri Jan 17, 2020 2:47 pm

I'm sorry but I can only add the parameters given by the CEF API and ICefResourceRequestHandler.OnResourceResponse doesn't have a "ResponseBody".

Post Reply