inject websocket headers at upgrade time

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.

inject websocket headers at upgrade time

Postby mezz » Mon Nov 12, 2018 11:40 am

Hi,
I need to inject custome headers in HTTP/websockets calls.
I managed to implement a resource handler provider which intercepts the "OnRequest(scoped_refptr<CefResourceManager::Request> request)" calls and injects the headers.
I managed to inject cookies as well.

I am able to the intercept the HTTP/S calls but not the websocket upgrades / wss calls. So I am not even able to see the initial websocket upgrade (HTTP/S) with the Connection: Upgrade header.

Am I doing something wrong? Is there a way of injecting websocket headers like standard cookies (which are headers as well)?

Thank you

Enrico
mezz
Techie
 
Posts: 15
Joined: Wed Oct 18, 2017 4:10 pm

Re: inject websocket headers at upgrade time

Postby magreenblatt » Mon Nov 12, 2018 2:24 pm

There is currently no mechanism for intercepting WebSockets calls. You might be able to create a WebSockets proxy server, perhaps using CefServer.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: inject websocket headers at upgrade time

Postby mezz » Mon Nov 12, 2018 3:19 pm

Thank you, we will try that then,

Enrico
mezz
Techie
 
Posts: 15
Joined: Wed Oct 18, 2017 4:10 pm

Re: inject websocket headers at upgrade time

Postby kristoff » Wed Feb 19, 2020 9:43 am

A bit late to the party, here I know, but how did this work out for you? I have the exact same need and feel somewhat lost...

/Kristoffer
kristoff
Newbie
 
Posts: 1
Joined: Wed Feb 19, 2020 9:38 am

Re: inject websocket headers at upgrade time

Postby dmklementiev » Wed Feb 19, 2020 3:18 pm

I've implemented a WebScoket server in c++ as a lib and it's always running in Cef as

Code: Select all
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser)
{
    CEF_REQUIRE_UI_THREAD();

    std::thread thread = std::thread([browser]()
    {
         Intialize WebSocket, bind to port;
         while(true)  // Actual condition involves checking to StopListening event.
        {
             Listen with callback
         }
    });

    thread.detach();


It's working fine for me, but Cefr gurus, please suggest if there is a better solution.
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 87 guests