Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebEngine: Websockets from Javascript have "null" origin
Forum Update on Monday, May 27th 2025

QWebEngine: Websockets from Javascript have "null" origin

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 348 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vic.ju
    wrote on 12 Jul 2022, 17:20 last edited by
    #1

    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.

    websocketstest.zip - 4 KB

    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

    V 1 Reply Last reply 18 Jul 2022, 16:26
    3
    • V Offline
      V Offline
      vic.ju
      wrote on 18 Jul 2022, 16:24 last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • V vic.ju
        12 Jul 2022, 17:20

        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.

        websocketstest.zip - 4 KB

        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

        V Offline
        V Offline
        vic.ju
        wrote on 18 Jul 2022, 16:26 last edited by
        #3

        As @tiptronic pointed out to me, it looks like the origin null is the proper result and file 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 Reply Last reply
        0

        1/3

        12 Jul 2022, 17:20

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved