Custom headers for SharedWorker script's GET request

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.

Custom headers for SharedWorker script's GET request

Postby AdishreeM » Tue Jan 14, 2020 7:59 am

I am trying to use SharedWorkers in my browser. To test, I made a simple script:

Code: Select all
 var worker = new SharedWorker('shared-worker.js');
    worker.port.start();
    worker.port.onmessage = function(e) {
      console.log('Main thread received a message from shared worker ', e);
    }
    worker.onerror = function(e) {
      console.log(e);
    }
    function pingShared(){
      console.log('Pinging shared worker..');
      worker.port.postMessage('ping');
    }


I need to add Authentication and other headers to the get request to obtain the "shared-worker.js" script requested in the first line above.
I have included the required logic in the BrowserResourceRequestHandler::OnBeforeResourceLoad function, but the control never reaches this function after the constructor tries to create the shared worker and get the script.
Hence, the request goes out without auth headers and server responds with a 401. But I checked the same logic using a regular dedicated worker using a WebWorker() constructor, where the control reaches the mentioned function, headers are getting added and the script is obtained correctly.

Any idea why this is happening or if I should treat SharedWorker script requests in a different manner?
AdishreeM
Newbie
 
Posts: 6
Joined: Tue Jan 14, 2020 5:23 am

Re: Custom headers for SharedWorker script's GET request

Postby magreenblatt » Tue Jan 14, 2020 9:51 am

What OS and CEF version?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Custom headers for SharedWorker script's GET request

Postby AdishreeM » Tue Jan 14, 2020 11:06 am

I am in Windows 10 and CEF 75.0.3770.100.

Are shared workers and dedicated workers treated differently in cef?
AdishreeM
Newbie
 
Posts: 6
Joined: Tue Jan 14, 2020 5:23 am

Re: Custom headers for SharedWorker script's GET request

Postby magreenblatt » Tue Jan 14, 2020 11:09 am

Can you try a supported CEF version? https://bitbucket.org/chromiumembedded/ ... -supported
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Custom headers for SharedWorker script's GET request

Postby AdishreeM » Tue Jan 14, 2020 11:54 am

Yes we are in the process of upgrading to the latest cef versions but it may take more some time. In the meantime, can you share some insights on how CEF handles sharedworker. SInce they can be accessed from different tabs and windows as opposed to a dedicated worker getting accessed only from the script from where it is created, is there any added functionality that needs to be taken care of?
AdishreeM
Newbie
 
Posts: 6
Joined: Tue Jan 14, 2020 5:23 am


Return to Support Forum

Who is online

Users browsing this forum: civilogic, Google [Bot] and 42 guests