Faking a webserver in CEF3

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Faking a webserver in CEF3

Postby nickb » Tue Apr 08, 2014 8:15 am

Hi,

I am looking to switch to CEF3 from CEF1, but I have one problem which I am not too sure how to fix. In CEF1 we used OnBeforeResourceLoad in CefRequestHandler to handle POST and GET request and deal with JSON data. This was a neat approach and meant that we could use code in the client as though it was a real web client, rather than, say, injecting a magic javascript object into the page.

This method still exists and I think should work fine for POST requests, but in the absence of a Response and a ResourceStream, what would be the best way of implementing a GET request? I have heard mention of the CefUrlRequest (eg here: http://www.magpcss.org/ceforum/viewtopi ... =6&t=10794) but I am unsure quite how to implement that. Any pointers?

-Nick
nickb
Techie
 
Posts: 13
Joined: Mon Oct 08, 2012 6:41 am

Re: Faking a webserver in CEF3

Postby magreenblatt » Tue Apr 08, 2014 9:59 am

magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Faking a webserver in CEF3

Postby nickb » Tue Apr 08, 2014 11:23 am

I've got something working by using GetResourceHandler and dealing with POST as we used to, but dealing with GET slightly differently - more like the code in the CEFClient example. If the GET request looks like one we want to handle, we create a CefStreamReader for the data and then a CefStreamResourceHandler, setting the mime type to application/json. Seems to work fine.

-Nick
nickb
Techie
 
Posts: 13
Joined: Mon Oct 08, 2012 6:41 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 82 guests