QWebEngine: Websockets from Javascript have "null" origin
-
wrote on 12 Jul 2022, 17:20 last edited by
Hello fellow Qt Developers,
I stumbled across a change in the Qt Webengine Chromium web sockets origin. Now I don't know if this is a bug or the expected behaviour.
Creating a websocket from a local html Javascript in the webengine produces different origins starting with Qt 6.3
-
Before Qt 6.3 (tested with 6.2.4):
The origin was properly set to "file://" -
Since Qt 6.3:
The origin returns "null"
I created a test project that spawns a Websocket server and a web view that loads a local html. The webpage creates a web socket in Javascript and connects back to the Qt websocket server so that we can easily take a look at the connection origin.
AFAIK there is no way to change the origin from the Javascript and "null" is not the correct origin. If this is a bug I will report it on the bug tracker, but I wanted to check first in the forum.
Best,
Victor -
-
wrote on 18 Jul 2022, 16:24 last edited byThis post is deleted!
-
Hello fellow Qt Developers,
I stumbled across a change in the Qt Webengine Chromium web sockets origin. Now I don't know if this is a bug or the expected behaviour.
Creating a websocket from a local html Javascript in the webengine produces different origins starting with Qt 6.3
-
Before Qt 6.3 (tested with 6.2.4):
The origin was properly set to "file://" -
Since Qt 6.3:
The origin returns "null"
I created a test project that spawns a Websocket server and a web view that loads a local html. The webpage creates a web socket in Javascript and connects back to the Qt websocket server so that we can easily take a look at the connection origin.
AFAIK there is no way to change the origin from the Javascript and "null" is not the correct origin. If this is a bug I will report it on the bug tracker, but I wanted to check first in the forum.
Best,
Victorwrote on 18 Jul 2022, 16:26 last edited byAs @tiptronic pointed out to me, it looks like the origin
null
is the proper result andfile
before was a bug.From the Mozilla documentation:
The Origin header value may be null in a number of cases, including (non-exhaustively):
- Origins whose scheme is not one of http, https, ftp, ws, wss, or gopher (including blob, file and data).
-
1/3