Retrieve HTTP version iso assuming that it is 1.1
authorKurt Pattyn <pattyn.kurt@gmail.com>
Thu, 22 Aug 2013 19:22:40 +0000 (21:22 +0200)
committerKurt Pattyn <pattyn.kurt@gmail.com>
Thu, 22 Aug 2013 19:22:40 +0000 (21:22 +0200)
According RFC 6455, the version must be bigger than or equal to 1.1, so we solved an incompatibility as well

source/websocket.cpp

index bae98f5..12ff60f 100644 (file)
@@ -807,7 +807,7 @@ void WebSocket::processHandshake(QTcpSocket *pSocket)
        bool ok = false;
        QString errorDescription;
 
-       const QString regExpStatusLine("^(HTTP/1.1)\\s([0-9]+)\\s(.*)");
+       const QString regExpStatusLine("^(HTTP/[0-9]+\\.[0-9]+)\\s([0-9]+)\\s(.*)");
        const QRegularExpression regExp(regExpStatusLine);
        QString statusLine = readLine(pSocket);
        QString httpProtocol;
@@ -850,9 +850,11 @@ void WebSocket::processHandshake(QTcpSocket *pSocket)
 
                if (httpStatusCode == 101)      //HTTP/1.1 101 Switching Protocols
                {
+                       bool conversionOk = false;
+                       float version = httpProtocol.midRef(5).toFloat(&conversionOk);
                        //TODO: do not check the httpStatusText right now
                        ok = !(acceptKey.isEmpty() ||
-                                  (httpProtocol.toLower() != "http/1.1") ||
+                                  (!conversionOk || (version < 1.1f)) ||
                                   (upgrade.toLower() != "websocket") ||
                                   (connection.toLower() != "upgrade"));
                        if (ok)