Page 1 of 1

retrieve response body in thread

Posted: Thu Jan 16, 2020 1:50 pm
by X11
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.

Re: retrieve response body in thread

Posted: Thu Jan 16, 2020 2:14 pm
by salvadordf
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/139 ... hin-thread

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

Re: retrieve response body in thread

Posted: Fri Jan 17, 2020 6:22 am
by X11
But is there no other way, without windows messaging api (Winapi.Messages)?

Re: retrieve response body in thread

Posted: Fri Jan 17, 2020 9:36 am
by X11
Can I use TCEFUrlRequestClientComponent in thread without Winapi.Messages?

Re: retrieve response body in thread

Posted: Fri Jan 17, 2020 10:00 am
by salvadordf
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.

Re: retrieve response body in thread

Posted: Fri Jan 17, 2020 2:16 pm
by X11
It would be very nice if you added one more parameter to the OnResourceResponse Event - ResponseBody :roll:

Re: retrieve response body in thread

Posted: Fri Jan 17, 2020 2:47 pm
by salvadordf
I'm sorry but I can only add the parameters given by the CEF API and ICefResourceRequestHandler.OnResourceResponse doesn't have a "ResponseBody".