summaryrefslogtreecommitdiff
path: root/src/websockets/qwebsocket_p.cpp
Commit message (Collapse)AuthorAgeFilesLines
* wasm: make sure connection is closed before being deletedLorn Potter2023-02-221-1/+7
| | | | | | | Pick-to: 6.5 Fixes: QTBUG-111248 Change-Id: I94a033fedf546c4d7f36af6c82a166dc33800f1f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix CMake Unity (Jumbo) buildsFriedemann Kleint2023-02-011-2/+0
| | | | | | | | | Move clashing constants to QWebSocketPrivate. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I6d22f2134683c2fb65b79732b991c7ff05338a8c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* wasm: fix heap-use-after-free when using deleteLaterLorn Potter2022-12-281-0/+4
| | | | | | | | | | | | QWebSocketPrivate was getting destroyed before the emscripten close callback was getting called, which was then calling back into the already destroyed object. So we set the UnconnectedState before it gets destroyed. Fixes: QTBUG-108996 Pick-to: 6.5 6.4 Change-Id: I8ebbe5a55188a31209a95d2a71eea2faee3465ad Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Pass number of items to a call to tr()Mårten Nordheim2022-12-211-3/+4
| | | | | Change-Id: I26214261662e466777b7438be13d91a0557f5e3c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Support 401 response for websocket connectionsMårten Nordheim2022-12-211-2/+105
| | | | | | | | | | | | | Adds the authenticationRequired signal. [ChangeLog][QWebSocket] QWebSocket now supports 401 Unauthorized. Connect to the authenticationRequired signal to handle authentication challenges, or pass your credentials along with the URL. Fixes: QTBUG-92858 Change-Id: Ic43d1c12529dea278b2951e6f991cc1004fc3713 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Rewrite translated string to not include '(s)'Mårten Nordheim2022-12-191-1/+1
| | | | | | | | | | | It is not always possible to translate such strings, and the number of occurrences don't matter, it's an error as soon as there is 1. Amends 99ebe2f669258b3919a0933ffd5d4c85fb13c0c0 Pick-to: 6.5 6.4 Change-Id: I4b12311813b26cd6e8e21e55826ec60dd301692a Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* Turn if..else if..else into a switchMårten Nordheim2022-12-151-3/+9
| | | | | | | Makes it a little nicer when adding new branches Change-Id: I1075c00c5bfc83d868adbc98d8c086f6065e9688 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Disconnect when handshake failsMårten Nordheim2022-12-151-0/+2
| | | | | | | | | It is unexpected that websocket does not disconnect once it knows the handshake has failed. Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I11e64745ffdb01c11ac79739cf7f384ad6cc4590 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QWebSocket: honor subprotocols specified with setRawHeaderMårten Nordheim2022-11-241-4/+26
| | | | | | | | | | | We would error out with a ConnectionRejected if the server accepted one of the protocols specified directly in the header since we did not consider those at all. Fixes: QTBUG-108276 Pick-to: 6.4 Change-Id: Ifbb316c9d4871fd764e03c74caefa10f5b757155 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QWebSocket: check correct variable in if-statementMårten Nordheim2022-11-221-1/+1
| | | | | | | | | It's _usually_ correct, but if all protocols have been filtered out then it will be an empty string. Pick-to: 6.4 Change-Id: I3aa3221b7e36cfd253cd1152b13e57183bf4f905 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Ic219197507870fd2b739f2e04ff138021e58d550 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove/replace uninitialized status line variable in error stringJuha Vuolle2022-10-051-2/+5
| | | | | | | | Amends: bbd9f2f4f5e0fda85029fa320f793973ea607c2b Pick-to: 6.3 6.4 Change-Id: I4af7b167e5f45ad5ead25f6421a2af8638494fd4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix uninitialized QWebSocket::errorString()Juha Vuolle2022-10-051-1/+1
| | | | | | | | | Amends: bbd9f2f4f5e0fda85029fa320f793973ea607c2b Fixes: QTBUG-106937 Pick-to: 6.3 6.4 Change-Id: Ia805df3e3dd8ba61e53592ebfb0a8bfae9184042 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace QWebSocket::error signal with QWebSocket::errorOccurredØystein Heskestad2022-08-031-20/+30
| | | | | | | | | | The signal error(QAbstractSocket::SocketError) is deprecated because it overloads the function error() and the naming does not match other similar signals. Fixes: QTBUG-101756 Change-Id: Ifbddef73ea39b03a6c72b0e09caa2031135d7687 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-101-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ief6ca28118c5ce0abe5dccf1854731cf2215e2b6 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix handshake looping infinitely making no progressMårten Nordheim2022-04-011-6/+9
| | | | | | | | | | | | | | | | | | | The processHandshake function may make no progress and return. The loop calling processHandshake previously had no way of knowing this and would happily loop forever despite the outcome being the same every time. This was particularly noticeable with any response that doesn't include the \r\n\r\n sequence the first time we call processHandshake. Since processHandshake either fails or succeeds, not performing any partial-reads, we simply move it out of the loop and restructure some of the code around it. Pick-to: 6.3 6.3.0 Fixes: QTBUG-102111 Change-Id: I3955e4b90eb1be0a0ef5dfcf8a46921a086a8b49 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Add support for WebSocket Sub-ProtocolsArno Rehn2022-03-301-15/+85
| | | | | | | | | | | | | | | | | Sub-Protocol support follows RFC 6455 Sections 4.1 and 4.2. See also https://datatracker.ietf.org/doc/html/rfc6455. This patch introduces a new class QWebSocketHandshakeOptions which collects options for the WebSocket handshake. At the moment, this contains only accessors for sub-protocols. In the future, it can be extended with things like WebSocket extensions. [ChangeLog] Add support for WebSocket Sub-Protocols Fixes: QTBUG-38742 Change-Id: Ibdcef17f717f0a76caab54f65c550865df1ec78d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix order of signals around disconnectionJoni Poikelin2022-02-011-3/+1
| | | | | | | | | | | | | | | | readyRead() signal had been connected with QueuedConnection which caused disconnected() signal to sometimes come before last message signals of a connection. Reasoning for this was some issue regarding SSL sockets, but there is a good chance it has been fixed since then. Removing this doesn't seem to cause hangs now at least. Fixes: QTBUG-100054 Pick-to: 6.3 6.2 Change-Id: Id465916d111a5520f4039cf57f822918f3afbca0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix setting of socket optionsJoni Poikelin2022-01-121-4/+8
| | | | | | | | Socket options need to be set after connectToHost() to take any effect. Change-Id: I006a8c59ba1c78d5edaa77d545bb0f640b7224fe Pick-to: 6.3 6.2 5.15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Reuse qtbase's HTTP header parser to avoid a reinvented wheelØystein Heskestad2021-12-091-1/+1
| | | | | | Fixes: QTBUG-80700 Change-Id: I7b713fd869ac802d5eee8ebb8d90a2115365b509 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Reuse header http parsing code from QtNetworkØystein Heskestad2021-10-081-173/+103
| | | | | | | Fixes: QTBUG-80701 Change-Id: Ic430a7dbc4448fc6d5fc000129a8e08bbed7e77d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Pass ignoreSslErrors to unterlying QSslSocketJens Trillmann2021-06-221-0/+5
| | | | | | | | | | | | When setting ignoreSslErrors(List<QSslError>) during the sslErrors signal handling the call got ignored. Only the internal config for creating a QSslSocket would be updated but not the current QSslSocket. The request of the caller to ignore specific QSslErrors would be ignored. Pick-to: 5.12 5.15 6.2 Change-Id: I6aaea2111fe1d26e07e6eaaa7532ae1b14a187a8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Make sure child QObjects get moved-to-thread along with the ownerMårten Nordheim2020-05-051-17/+16
| | | | | | | | | | | | | | | By parenting them. And to do that without crashing they need to be allocated dynamically. A couple missed "parenting"s caused the object to not be moved to the other thread when the websocket was moved. This caused it to print warnings when the timer was started and stopped since this cannot be done across threads. Fixes: QTBUG-83722 Pick-to: 5.15 Change-Id: Iee60fe1c498f8f6d1e0c2cfcb2923bd5b9560acb Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-311-8/+84
|\ | | | | | | Change-Id: I7b3d96575073eb6537b40286c027074969bf8076
| * QAbstractSocket: Fix warnings from deprecated error signalv5.15.0-beta4v5.15.0-beta3Mårten Nordheim2020-03-231-2/+1
| | | | | | | | | | | | Task-number: QTBUG-82605 Change-Id: Ibaa722ae26a71680426cecc3a0e25acc72d9527b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
| * Add a public api to set max frame and message size (CVE-2018-21035)Franck Dude2020-03-191-6/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | This change allows the user to set a lower allowed frame/message size for reception. The purpose is to avoid an attacker to exhaust the virtual memory of the peer. Fixes CVE-2018-21035 [ChangeLog] Added public API to set the maximum frame size and message size Task-number: QTBUG-70693 Change-Id: I5dc5918badc99166afdcc8d9c6106247a9f8666f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-071-2/+1
|\ \ | |/ | | | | Change-Id: Ib31d3b50e4498cdfc55b68ebc5993750b5ee7ce1
| * Use Qt::SplitBehavior in preference to QString::SplitBehaviorEdward Welbourne2020-03-021-2/+1
| | | | | | | | | | | | | | | | The Qt version was added in 5.14 "for use as eventual replacement for QString::SplitBehavior." Move another step closer to that goal. Change-Id: If65be10a7c86e7b4173fd31f1d277c63c6accb0a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-02-291-1/+1
|\ \ | |/ | | | | Change-Id: Ib6762714c19354c7adbf0c032d2f9995f576114f
| * Revert "QWebSocket - do not use deprecated member-function"Allan Sandfeld Jensen2020-02-271-1/+1
| | | | | | | | | | | | | | | | | | This reverts commit 938ad6373415fa8b0767a987c37ce51ec546859f. Reason for revert: Was undeprecated and replacement removed Change-Id: I79d6e931d72ec518a43fe058e1067b3754f6cf05 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-281-2/+2
|\ \ | |/ | | | | Change-Id: I7434fcdb376d1227fff3ebe28f614736e7efb395
| * Change QMap to QMultiMapMårten Nordheim2020-01-231-2/+2
| | | | | | | | | | | | | | Because insertMulti is deprecated Change-Id: I3965ea7159b2516b35c45072115eba1ab621b89a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Merge "Merge remote-tracking branch 'origin/5.15' into dev"Qt Forward Merge Bot2020-01-211-1/+1
|\ \ | |/
| * QWebSocket - do not use deprecated member-functionTimur Pocheptsov2020-01-151-1/+1
| | | | | | | | | | | | | | | | Use 'socketError' instead. Task-number: QTBUG-80369 Change-Id: I30527721677be0fc0f71ca33b08f608472bc8b71 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Use the new functions/signals introduced in QSslSocketLars Schmertmann2020-01-211-0/+20
|/ | | | | | Task-number: QTBUG-68419 Change-Id: Icdc41079cb946d4316cc0ec2ae40522e6de52725 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-12-141-6/+2
|\ | | | | | | Change-Id: Icd1a2fd565d5d85ac6d1378578a92dbb1a9692ce
| * Don't add port in Host header unless specifiedLander Noterman2019-11-211-6/+2
| | | | | | | | | | | | | | | | | | | | | | No longer add port to Host header in WebSocket handshake unless it was explicitly specified in the URL. This change fixes issues with some WebSocket servers rejecting the connection if the Host header does not match the URL. Fixes: QTBUG-77526 Change-Id: I9b028ce434416e61cae7b217d2eafe621d2660b4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Fix websocket handshake request header parsingFranck Dude2019-12-131-1/+5
|/ | | | | | | | | | | Header ends with \r\n\r\n but there might be more data inside the tcpbuffer Never read past the header Task-number: QTBUG-70000 Change-Id: If3d4cb362646e43a91faf00f89e50510ff00fa56 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Take 2: Properly handle multiple websocket frames in one TCP frameMårten Nordheim2019-08-281-1/+1
| | | | | | | | | | | | | Gerrit ate my change and somehow created an impossible state where a patch was able to merge due to its fix but couldn't actually pass its tests. Amends 6e1fa958c289de639753a60a9384bd94db0e91a8 Task-number: QTBUG-77830 Change-Id: Iedc23616816bb2c1758969a1d76b9536b509c38a Reviewed-by: Ryan Chu <ryan.chu@qt.io> Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* QWebsocket doesn't receive message with size larger than 1MRyan Chu2019-08-281-2/+2
| | | | | | | | | | | | If the processing of QWebSocketFrame is not done and waiting for more data, QWebSocketPrivate::processData should return the control and wait for next readyRead signal. Continue the change of b2fc794ffaf48c9d9c401b54cf39ea0220617a27 Change-Id: Idf5af0710267e59e63b8e234d6dab5843d821696 Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Merge dev into 5.14Kari Oikarinen2019-08-271-2/+2
|\ | | | | | | Change-Id: I2eaffbe6e9519a78d0f8663c0870f24cb006d222
| * Remove waitForReadyRead from QWebSocketFrame::readFrameRyan Chu2019-08-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Asynchronously process socket frame in QWebSocketDataProcessor::process. If the processing of QWebSocketFrame is not done and waiting for more data, QWebSocketDataProcessor::process will return the control and wait for next readyRead signal to continue processing the unfinished socket frame. QWebSocketDataProcessor::process gets timeout after 5 seconds, and then an errorEncountered signal will be emitted. Fixes: QTBUG-74464 Change-Id: I03b7f874c1c266617e7eadf59c59ae43fa8540ce Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Use QElapsedTimer instead of QTime for the ping timerFriedemann Kleint2019-08-231-0/+2
|/ | | | | | | | | The use of QTime for determining intervals is deprecated: qwebsocket_p.cpp:1214:61: warning: ‘int QTime::elapsed() const’ is deprecated: Use QElapsedTimer instead [-Wdeprecated-declarations] Change-Id: I26e1dabcba5ba54a4fead02b43c3fe7ace740be0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* wasm: fix validity statev5.13.0-beta1Lorn Potter2019-03-111-0/+2
| | | | | | | Fixes:QTBUG-73689 Change-Id: I5993eb38a8fc45a06a8ced46f71034e4b87ec67b Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Set the protocol type so that PAC scripts handle ws/wss correctlyAndy Shaw2018-12-261-0/+2
| | | | | | | | | On macOS it will only allow proxies in a PAC script to use http/https protocols, so this enables them to work by automatically setting these as the type instead. Change-Id: I66589057d40d135229cbae4986ef0819287ea69a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Remove unneeded CRLF ending from status lineAleksey Lysenko2018-12-211-1/+1
| | | | | | | | | No need to keep the CRLF ending of status line. Task-number: QTBUG-67424 Change-Id: I7f94c7bedf40412b338c56cfe59751f6a9e78f0a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Add support for WebSockets on Qt for WASMLorn Potter2018-09-201-0/+8
| | | | | | | | | Implement the QWebSocket API using HTML WebSocket. Change-Id: I2284f8606d512943d2abc2a96fc48effcc45a786 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove unnecesary default labelJesus Fernandez2018-08-141-2/+0
| | | | | | Change-Id: I994b34614b2e2ee95fed145e7f5dcd873ff7c3f4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix conversion warningsJesus Fernandez2018-08-141-8/+12
| | | | | | Change-Id: I087b72412db19f34b8e890ddc6a3a0fcdd434141 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use QObjectPrivate::q_ptr instead of shadowing itJesus Fernandez2018-08-141-9/+6
| | | | | | | | | | Some private classes had a q_ptr pointer shadowing the QObjectPrivate::q_ptr pointer. Q_Q casts the QObjectPrivate::q_ptr pointer to match the public class so there is no need to store a different pointer. Change-Id: I8f5c4323b1dcf45a9796c0dd9f522bdbc63add18 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>