Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-120492

QWebSocket connecting to an URL without a path sends GET request without leading /

    XMLWordPrintable

Details

    Description

      I am not sure if this is a bug in QUrl or in QWebSocket, or maybe it isn't a bug at all. However, some servers don't accept GET request that doesn't start with /. For example this has no path at all:

      QUrl("http://foo.bar?x=y")
      

      and the server receives just:

      GET ?x=y HTTP/1.1
      

      And the lack of / there is considered an error with some web servers.

      After doing some digging... According to:
      https://datatracker.ietf.org/doc/html/rfc6455#section-3

      A valid WebSocket URI has path as defined in path-abempty in URI spec, and URI spec says path-abempty is a path starting with leading / or is empty. But WebSocket uses QNetworkRequest, which in turn takes in QUrl, which as the name implies is for URLs in general and not WebSocket specific URIs. Therefore no validation is possible.

      So there is a small design issue at least, but I am guessing it would probably be fine to just make it start the path with / if the path() is empty.

      Attachments

        1. qtbug120492.zip
          2 kB
          Joni Poikelin
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            poikelin Joni Poikelin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes