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

QtWebSockets checks HTTP headers without ignoring case.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.3.0 RC1
    • 5.3.0 Beta1
    • WebSockets
    • None
    • MacOSX, Windows, Linux

    Description

      On connect if the HTTP headers are not cased exactly as the string literals in the source, then a connection will not be made, and the error message around line 926 of src/websockets/qwebsocket_p.cpp is shown (it says "QWebSocketPrivate::processHandshake: Invalid statusline in response: %1."), but the status line will be a perfectly legal status line:

      HTTP/1.1 101 Switching Protocols

      This error message is given because of the if statement around line 917, which tests for much more than a bad status line: specifically it tests to see if some string values pulled from a QMap<QString,QString> have expected values. They have empty string values if the HTTP headers are not cased the same as the string literals in the source.

      In other words, the code expects a response such as

      HTTP/1.1 101 Switching Protocols
      Upgrade: websocket
      Connection: Upgrade
      Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
      Sec-WebSocket-Protocol: chat

      when what is received is

      HTTP/1.1 101 Switching Protocols
      upgrade: websocket
      connection: Upgrade
      sec-websocket-accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
      sec-websocket-protocol: chat

      (Note the capitalization of the header keys).

      A possible fix is to change the line around 190 from

      headers.insertMulti(headerField[0], headerField[1]);

      to

      headers.insertMulti(headerField[0].toLower(), headerField[1]);

      , and changing all string literals that act as keys to this QMap to be lower case (it's a local variable, and there are only 2 or 3 of such literals).

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            nierob Nierob
            jaysistar Jay Sistar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes