CEF: Intercepting http calls with CefResourceHandler. UI is not getting rendered.

2,073 views
Skip to first unread message

jaison jose

unread,
Sep 23, 2014, 9:01:42 AM9/23/14
to cef...@googlegroups.com

using Xilium.CefGlue

I need to intercept http calls for caching purpose-if UI/Data is already cached- then I want to return the cached data, else get response from server and cache it for next time.

What are the correct steps to achieve it?

·         Create my own CefResourceHandler and CefSchemeHandlerFactory and handle requests in ProcessRequest() call?

·         Create my own CefRequestHandler and handle requests in OnBeforeResourceLoad()?

With GetResourceHandler, I am able to get ProcessRequest() calls. With callback.Continue(); and return true; I get immediate calls to GetResponseHeaders() and ReadResponse().

In GetResponseHeaders(), redirectUrl is set to null.

I see the url loaded on browser if I am not using my own CefResourceHandler. With my own handler, UI is not getting rendered.

What is missing here - a new thread callback invocation from ReadResponse()??

Czarej Tomczak

unread,
Sep 23, 2014, 11:15:20 AM9/23/14
to cef...@googlegroups.com
Take a look at an implementation using Python, see detailed comments in ResourceHandler:

One tricky thing I remember is that there are always two calls to ReadResponse. If data is available immediately return True, but await a second call and return False.

Czarej Tomczak

unread,
Sep 23, 2014, 11:17:17 AM9/23/14
to cef...@googlegroups.com
*One tricky thing I remember is that there are always at leat two calls to ReadResponse.

jaison jose

unread,
Sep 24, 2014, 10:56:11 AM9/24/14
to cef...@googlegroups.com
Thank you Czarej. I followed your python example and I am able to get the workflow correct now.

The js file which I received results in a syntax error -Unexpected token ILLEGAL. As per stack overflow, it is due to some special character issue and I amworking on it now.

Thanks for the timely help. :)
Reply all
Reply to author
Forward
0 new messages