Behavior of IRequestHandler/IResourceRequestHandler

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

Behavior of IRequestHandler/IResourceRequestHandler

Postby AmpelioAttanasi » Fri Mar 18, 2022 9:34 am

Hi all,

we use CEF/CefSharp for our application and we can't get to understand the behavior in some cases of the IRequestHandler/IResourceRequestHandler.
We have a very simple class implementing the two above interfaces to intercept the GetResourceResponseFilter calls and read the content of the ResourceResponse through a MemoryStreamResponseFilter. Things work as expected as long as the local cache is empty, otherwise we miss all the calls to the two interfaces' methods.

This behavior is somehow reproducible, for example, going on the vscode.dev site: in the first run we can see the list of events for 60-something files, the second attempt only for 26 of them.
(attaching sample used and output).

If i remove the local cache from disk all the events are received again.
Am I doing something wrong?
How can I get notified of these event every time for all the files?
Thanks,

AA
Attachments
CefSharpTest.zip
(16.02 KiB) Downloaded 383 times
AmpelioAttanasi
Techie
 
Posts: 11
Joined: Tue Aug 03, 2021 3:42 am

Re: Behavior of IRequestHandler/IResourceRequestHandler

Postby amaitland » Fri Mar 18, 2022 2:21 pm

What version are you using?

CefSharp just provides a wrapper around CefResourceHandler and CefResourceRequestHandler.

Perhaps CEF requires changes.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Behavior of IRequestHandler/IResourceRequestHandler

Postby magreenblatt » Fri Mar 18, 2022 3:11 pm

In general, I don't think cached responses can be intercepted. Is it caching the original version or your filtered version of the resource response?
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Behavior of IRequestHandler/IResourceRequestHandler

Postby AmpelioAttanasi » Mon Mar 21, 2022 3:24 am

> What version are you using?

I'm using these versions:

Code: Select all
"cef.redist.x64" version="99.2.9"
"cef.redist.x86" version="99.2.9"
"CefSharp.Common" version="99.2.90"
"CefSharp.WinForms" version="99.2.90"


but I've also tested this with previous versions and the behavior seems the same.

> Is it caching the original version or your filtered version of the resource response?

It seems that it is actually caching everything - in our actual use case, our filter is just used to "inspect" the files of the request (we need to parse an XML file of one of our Javascript applications for licensing purpose), so it doesn't filter out anything. The behavior we see is this:

- starting from a "clean situation" (local cache is not present) we load the Javascript application in a browser and all the files are notified through the IRequestHandler/IResourceRequestHandler methods
- if we open another browser instance and we go to the JS application, we don't get any notification
- if we completely close/restart the application and we load again the JS application, nothing is received in the methods of the interfaces
- if we delete the local cache, the requests are notified again

So, it seems that local cache is preventing the notifications in the interfaces to work, which is quite a problem for us: are there other solutions to always get all the downloaded/loaded files before they are used in the browser?
Or ways to disable cache for specific files/sites? I guess disabling the cache would also break cookies storage, which would be a problem for JS applications that needs a login and uses cookies to avoid relogin every time.
Thanks,

AA
AmpelioAttanasi
Techie
 
Posts: 11
Joined: Tue Aug 03, 2021 3:42 am

Re: Behavior of IRequestHandler/IResourceRequestHandler

Postby magreenblatt » Mon Mar 21, 2022 8:45 am

You can try setting Cache-Control headers on the resources that you want to always intercept.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm


Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 12 guests