diff options
Diffstat (limited to 'src/websockets/qwebsocketprotocol.cpp')
-rw-r--r-- | src/websockets/qwebsocketprotocol.cpp | 122 |
1 files changed, 64 insertions, 58 deletions
diff --git a/src/websockets/qwebsocketprotocol.cpp b/src/websockets/qwebsocketprotocol.cpp index 3b5c52d..efcc313 100644 --- a/src/websockets/qwebsocketprotocol.cpp +++ b/src/websockets/qwebsocketprotocol.cpp @@ -59,19 +59,19 @@ QT_BEGIN_NAMESPACE The close codes supported by WebSockets V13 - \value CC_NORMAL Normal closure - \value CC_GOING_AWAY Going away - \value CC_PROTOCOL_ERROR Protocol error - \value CC_DATATYPE_NOT_SUPPORTED Unsupported data - \value CC_RESERVED_1004 Reserved - \value CC_MISSING_STATUS_CODE No status received - \value CC_ABNORMAL_DISCONNECTION Abnormal closure - \value CC_WRONG_DATATYPE Invalid frame payload data - \value CC_POLICY_VIOLATED Policy violation - \value CC_TOO_MUCH_DATA Message too big - \value CC_MISSING_EXTENSION Mandatory extension missing - \value CC_BAD_OPERATION Internal server error - \value CC_TLS_HANDSHAKE_FAILED TLS handshake failed + \value CloseCodeNormal Normal closure + \value CloseCodeGoingAway Going away + \value CloseCodeProtocolError Protocol error + \value CloseCodeDatatypeNotSupported Unsupported data + \value CloseCodeReserved1004 Reserved + \value CloseCodeMissingStatusCode No status received + \value CloseCodeAbnormalDisconnection Abnormal closure + \value CloseCodeWrongDatatype Invalid frame payload data + \value CloseCodePolicyViolated Policy violation + \value CloseCodeTooMuchData Message too big + \value CloseCodeMissingExtension Mandatory extension missing + \value CloseCodeBadOperation Internal server error + \value CloseCodeHandshakeFailed TLS handshake failed \sa QWebSocket::close() */ @@ -85,33 +85,38 @@ QT_BEGIN_NAMESPACE For an overview of the differences between the different protocols, see <http://code.google.com/p/pywebsocket/wiki/WebSocketProtocolSpec> - \value V_Unknow - \value V_0 hixie76: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76 & - hybi-00: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00. - Works with key1, key2 and a key in the payload. - Attribute: Sec-WebSocket-Draft value 0. - \value V_4 hybi-04: http://tools.ietf.org/id/draft-ietf-hybi-thewebsocketprotocol-04.txt. - Changed handshake: key1, key2, key3 - ==> Sec-WebSocket-Key, Sec-WebSocket-Nonce, Sec-WebSocket-Accept - Sec-WebSocket-Draft renamed to Sec-WebSocket-Version - Sec-WebSocket-Version = 4 - \value V_5 hybi-05: http://tools.ietf.org/id/draft-ietf-hybi-thewebsocketprotocol-05.txt. - Sec-WebSocket-Version = 5 - Removed Sec-WebSocket-Nonce - Added Sec-WebSocket-Accept - \value V_6 Sec-WebSocket-Version = 6. - \value V_7 hybi-07: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07. - Sec-WebSocket-Version = 7 - \value V_8 hybi-8, hybi-9, hybi-10, hybi-11 and hybi-12. - Status codes 1005 and 1006 are added and all codes are now unsigned - Internal error results in 1006 - \value V_13 hybi-13, hybi14, hybi-15, hybi-16, hybi-17 and RFC 6455. - Sec-WebSocket-Version = 13 - Status code 1004 is now reserved - Added 1008, 1009 and 1010 - Must support TLS - Clarify multiple version support - \value V_LATEST Refers to the latest know version to QWebSockets. + \value VersionUnknow Unknown or unspecified version. + \value Version0 hixie76: + http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76 & + hybi-00: + http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00. + Works with key1, key2 and a key in the payload. + Attribute: Sec-WebSocket-Draft value 0. + \value Version4 hybi-04: + http://tools.ietf.org/id/draft-ietf-hybi-thewebsocketprotocol-04.txt. + Changed handshake: key1, key2, key3 + ==> Sec-WebSocket-Key, Sec-WebSocket-Nonce, Sec-WebSocket-Accept + Sec-WebSocket-Draft renamed to Sec-WebSocket-Version + Sec-WebSocket-Version = 4. + \value Version5 hybi-05: + http://tools.ietf.org/id/draft-ietf-hybi-thewebsocketprotocol-05.txt. + Sec-WebSocket-Version = 5 + Removed Sec-WebSocket-Nonce + Added Sec-WebSocket-Accept. + \value Version6 Sec-WebSocket-Version = 6. + \value Version7 hybi-07: + http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07. + Sec-WebSocket-Version = 7. + \value Version8 hybi-8, hybi-9, hybi-10, hybi-11 and hybi-12. + Status codes 1005 and 1006 are added and all codes are now unsigned + Internal error results in 1006. + \value Version13 hybi-13, hybi14, hybi-15, hybi-16, hybi-17 and RFC 6455. + Sec-WebSocket-Version = 13 + Status code 1004 is now reserved + Added 1008, 1009 and 1010 + Must support TLS + Clarify multiple version suppor.t + \value VersionLatest Refers to the latest known version to QtWebSockets. */ /*! @@ -121,22 +126,22 @@ QT_BEGIN_NAMESPACE The frame opcodes as defined by the WebSockets standard - \value OC_CONTINUE Continuation frame - \value OC_TEXT Text frame - \value OC_BINARY Binary frame - \value OC_RESERVED_3 Reserved - \value OC_RESERVED_4 Reserved - \value OC_RESERVED_5 Reserved - \value OC_RESERVED_6 Reserved - \value OC_RESERVED_7 Reserved - \value OC_CLOSE Close frame - \value OC_PING Ping frame - \value OC_PONG Pong frame - \value OC_RESERVED_B Reserved - \value OC_RESERVED_C Reserved - \value OC_RESERVED_D Reserved - \value OC_RESERVED_E Reserved - \value OC_RESERVED_F Reserved + \value OpCodeContinue Continuation frame + \value OpCodeText Text frame + \value OpCodeBinary Binary frame + \value OpCodeReserved3 Reserved + \value OpCodeReserved4 Reserved + \value OpCodeReserved5 Reserved + \value OpCodeReserved6 Reserved + \value OpCodeReserved7 Reserved + \value OpCodeClose Close frame + \value OpCodePing Ping frame + \value OpCodePong Pong frame + \value OpCodeReservedB Reserved + \value OpCodeReservedC Reserved + \value OpCodeReservedD Reserved + \value OpCodeReservedE Reserved + \value OpCodeReservedF Reserved \internal */ @@ -170,10 +175,11 @@ QT_BEGIN_NAMESPACE QWebSocketProtocol::Version QWebSocketProtocol::versionFromString(const QString &versionString) { bool ok = false; - Version version = V_Unknow; + Version version = VersionUnknown; const int ver = versionString.toInt(&ok); QSet<Version> supportedVersions; - supportedVersions << V_0 << V_4 << V_5 << V_6 << V_7 << V_8 << V_13; + supportedVersions << Version0 << Version4 << Version5 << Version6 << Version7 << Version8 + << Version13; if (Q_LIKELY(ok) && (supportedVersions.contains(static_cast<Version>(ver)))) version = static_cast<Version>(ver); return version; |