Intercept AJAX requests using JCEF

Having problems with building or using the JCEF Java binding? Ask your questions here.

Intercept AJAX requests using JCEF

Postby nicolae » Fri Oct 10, 2014 4:48 am

Hello,

Is it possible to intercept network requests, like AJAX, using JCEF?

I have read this thread viewtopic.php?f=10&t=11685 and I am aware that a workaround would be to use javascript bindings but I am wondering if the actual AJAX interception has been implemented or if there are plans to do so?

Thanks
nicolae
Techie
 
Posts: 10
Joined: Wed Oct 08, 2014 11:20 am

Re: Intercept AJAX requests using JCEF

Postby me12 » Fri Oct 10, 2014 5:48 am

You can define custom scheme handlers and intercept your requests in those.
me12
Techie
 
Posts: 31
Joined: Thu Jul 10, 2014 12:46 pm

Re: Intercept AJAX requests using JCEF

Postby Czarek » Fri Oct 10, 2014 5:49 am

In CefRequestHandler::onBeforeResourceLoad you can intercept request before it is being sent. Most javascript frameworks including jQuery add a X-Requested-With: XMLHttpRequest header that allows to identify AJAX requests. To intercept response you need to implement CefRequestHandler::getResourceHandler.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Intercept AJAX requests using JCEF

Postby nicolae » Fri Oct 10, 2014 9:46 am

Thanks! Works.

For some reason I assumed that CefRequestHandler can't do this for AJAX calls too, but I see now that this class was actually implemented after the thread I mentioned in my first post was opened http://code.google.com/p/javachromiumem ... estHandler
nicolae
Techie
 
Posts: 10
Joined: Wed Oct 08, 2014 11:20 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 19 guests