summaryrefslogtreecommitdiff
path: root/src/websockets/qwebsocket.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Support 401 response for websocket connectionsMårten Nordheim2022-12-211-0/+21
| | | | | | | | | | | | | 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>
* Doc: Remove usages of the second argument of a "\page" commandLuca Di Sera2022-09-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The "\page" command for QDoc, used to construct a standalone documentation page in the output documentation of a project, was able to take a second argument, apart from the first argument representing the name for the generated documentation page, that roughly represented the type of the page that was to be generated. This second argument was not actually used by QDoc, such that it had no meaningful effect. QDoc was recently modified to not support this second argument, internally, and officially removed its use. For technical legacy reason, QDoc will still support the usage of a second argument for a "\page" command, albeit it will do nothing, as before. To avoid confusion for future readers who might not be aware of the history of the "\page" argument and that will not find an explanation in QDoc's documentation anymore, the usages of the second argument in "\page" commands are now removed. Change-Id: Ia41f57d5afd76b0c369f58b3f9c25854e55a33fc Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Replace QWebSocket::error signal with QWebSocket::errorOccurredØystein Heskestad2022-08-031-12/+21
| | | | | | | | | | 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>
* Add support for WebSocket Sub-ProtocolsArno Rehn2022-03-301-5/+58
| | | | | | | | | | | | | | | | | 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>
* Update since markersAllan Sandfeld Jensen2021-07-161-5/+5
| | | | | | | | | Qt 6.2 will be first Qt 6 release for Qt WebSockets Pick-to: 6.2 Change-Id: I2141785c3f5bf6604418e3d1b8d8c311c916400d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Add doc note about internal ping/pong handlingAndre Hartmann2020-12-211-0/+3
| | | | | | | Pick-to: 5.15 Change-Id: Ic74407b17d03fbfd3077ac1dd4f689a7207ccb51 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Update dependencies on 'dev' in qt/qtwebsocketsLiang Qi2020-07-011-4/+4
| | | | | | | | Also adapt to qtbase 45c0f45e04, Move QAlertLevel and QAlertType enums into the namespace QSsl. Change-Id: I3ddbbdaf22127fe0478ce7fac5879ed36bea0b30 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-311-0/+111
|\ | | | | | | Change-Id: I7b3d96575073eb6537b40286c027074969bf8076
| * Add a public api to set max frame and message size (CVE-2018-21035)Franck Dude2020-03-191-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Use the new functions/signals introduced in QSslSocketLars Schmertmann2020-01-211-0/+77
|/ | | | | | Task-number: QTBUG-68419 Change-Id: Icdc41079cb946d4316cc0ec2ae40522e6de52725 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Use QObjectPrivate::q_ptr instead of shadowing itJesus Fernandez2018-08-141-2/+2
| | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-08-071-1/+4
|\ | | | | | | Change-Id: Iffe66da51d3b7b38d04ca3c185b3b003b157f886
| * Limit Close frame to 125 bytesMårten Nordheim2018-08-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | All control frames should be limited to 125 frames. https://tools.ietf.org/html/rfc6455#section-5.5 Task-number: QTBUG-62949 Change-Id: Id9b5a431faab6ff6edf7dc2e5c3525e999bc04ea Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* | QWebSocket: Add 'bytesToWrite'Mårten Nordheim2018-04-141-0/+13
|/ | | | | | | | | | | | | | | | Add the well-known 'bytesToWrite' function to QWebSocket. Previously the only way to know how many bytes were left to be written was to make a guesstimate on the overhead your message would get and then keep track of the amount sent using the 'bytesWritten' signal. The tests compare using '>' because there is overhead from the headers. [ChangeLog][QWebSocket] Added the bytesToWrite function to QWebSocket. Call this function to see how many bytes are left to write. Change-Id: I82f17a98b582ee3bc02f0c47597b4a6717761f12 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-11-201-1/+1
|\ | | | | | | | | | | | | | | Conflicts: src/websockets/qwebsocket_p.cpp tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp Change-Id: I40922fab198a09a3fbba1b2f11b42f2d40e53720
| * Update to new QRandomGenerator APIv5.10.0-beta4Thiago Macieira2017-11-031-1/+1
| | | | | | | | | | | | Change-Id: I69f37f9304f24709a823fffd14e676c097712329 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Replace Q_NULLPTR with nullptrKevin Funk2017-09-261-1/+1
|/ | | | | Change-Id: I0988a4119b5bd790d286c16b5647d97d4d95aef0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Change the mask generator to use QRandomGenerator instead of qs?randThiago Macieira2017-06-301-2/+2
| | | | | | | | | This makes it secure, instead of insecure, and requires no seeding. Task-number: QTBUG-61694 Change-Id: Ia53158e207a94bf49489fffd14c782bd4ec24946 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Add support for TLS PSK (client and server)André Klitzing2016-06-121-0/+22
| | | | | | | [ChangeLog][QWebSocket] It is now possible to use TLS PSK ciphersuites. Change-Id: I9e96669494cec5e6a4e076fe9f10fcd4ef6358a4 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-beta1Liang Qi2016-04-081-8/+8
|\ | | | | | | Change-Id: I7ebcdc16a8b65103abfb9640c990eddbeccdef05
| * Doc: Add external-resources.qdocKai Koehne2016-04-071-8/+8
| | | | | | | | | | | | | | | | | | Also sanitize some linking, e.g. by referencing to the paper by title, not by link. Change-Id: I95482994ca569001a23a3beb0e3cbe6739f4ed77 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
* | Updated license headersAntti Kokko2016-01-201-14/+20
|/ | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I8c17da1f7e2f0a620e3627fa7f8087f185545c8a Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-10-021-0/+2
|\ | | | | | | | | | | | | Conflicts: tests/auto/websockets/qwebsocket/tst_qwebsocket.cpp Change-Id: Ie4184b0788b6a0a5a85ca8e4d1547c33f7027ca0
| * Set parent of internal socket objectsPeter Kümmel2015-09-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After moving the websocket into another thread current code doesn't work because then the QTcpSocket/QSslSocket objects reside in a different thread, for instance: "QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread" QObject::moveToThread(QThread*) also moves QObjects's children, therefore their internal socket objects need to be children of QWebSocket. QWebSocket has ownership of the internal socket, and the smart pointer is not needed any more. Change of cleanup code to prevent crashes with clang/msvc builds: QWebSocketPrivate is a scoped member of QObject (not QWebSocket) and is destroyed after QObject destructor body was executed, and so m_pSocket&co had already been destroyed (being children) when the destructor of QWebSocketPrivate is called via the scoped pointer. Analogous to 64927e04f202d33b9a9a1f94141ef692c0b513ac Change-Id: I1ade6cda3fa793c30332cc5e103025e2dda3c78c Reviewed-by: Luca Niccoli <lultimouomo@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Send and parse headers for the handshake requestLuca Niccoli2015-05-261-0/+2
| | | | | | | | | | | | Task-number: QTBUG-40842 Change-Id: I02787a0e55701966e564a312d51297f4160bd89a Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
* | Add open(const QNetworkRequest &) and request()Luca Niccoli2015-04-081-2/+25
|/ | | | | | | | | | | Request headers are not yet handled, only the QNetworkRequest::url() is taken into consideration. [ChangeLog][QWebSocket] Added open(const QNetworkRequest &) and request() Task-number: QTBUG-40842 Change-Id: Ia2e10f22c79b0a085afb9a2eb8437b7a73d4a045 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-161-6/+6
| | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I8467410bfad44e8d3fe6bd5724c61bb0c07c91f9 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com> Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
* Improve the integration of QtWebsockets into general Qt docsv5.4.0-beta1Alex Blasche2014-09-281-0/+1
| | | | | | | | | | | | | 1.) The websocket qml types page is now hooked into Qt's QML Type by Module page. 2.) Correct incorrectly documented import statement for Qt.WebSockets module in QML. 3.) Add missing \since tags (see QTBUG-36775). Change-Id: I1321db70215fcd16cfbd77dd71a459244241d8a3 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Update license headers and add new license filesv5.4.0-alpha1Antti Kokko2014-08-241-18/+10
| | | | | | | - Added LICENSE.LGPLv3, LICENSE.GPLv2 & LICENSE.LGPLv21 Change-Id: I0586e35a7aa99be1b5b3bda580b05897f451acbf Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Use the proper protocol namesSze Howe Koh2014-04-091-8/+8
| | | | | | | | - "WebSocket" is one word, with uppercase 'W' and 'S'. - "HTTP"/"HTTPS" is fully uppercase Change-Id: Ice3a50c94394433c97f7347291af5cda69b234ce Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Doc: Language/writ. guidelines review Qt WebSocketsNico Vertriest2014-03-141-7/+7
| | | | | | | Task-number: QTBUG-37149 Change-Id: Ic0c28928404fc515de40e6fdff11849cdb2929d6 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Update documentation.Kurt Pattyn2014-03-111-0/+4
| | | | | Change-Id: I8fca0df0ea66adba0898d95f8249ea1b7f33892a Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Adapt copyright headerKurt Pattyn2014-02-151-1/+1
| | | | | Change-Id: I9773492d3673d8aabdb4dd178be6af12eca7ba74 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add user configurable mask generationKurt Pattyn2014-02-151-1/+31
| | | | | | | | | Created a QMaskGenerator abstract base class to serve as a basis for user specific mask generators. Added the possibility to override the default mask generation in QWebSocket. Change-Id: Iaa02b44193f854d103b5f352617789175fe61f89 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Check on newline characters in origin and urlsKurt Pattyn2014-02-111-0/+5
| | | | | | | | | | New line characters (\r\n) in the resource part of a url and in the origin string can be used to forge the http header and can lead to insertion of unwanted header entries. This can be an indication of an attack, so QWebSocket immediately refuses a connection. Change-Id: I9cdb309bfbe7025ad675925e6ea3e038476a1fd6 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Sanitize open() methodKurt Pattyn2014-02-071-5/+2
| | | | | | | | | Removed the mask parameter because a web socket client does not have a choice between masking and not masking. Change-Id: I3c33acc235bb2a99476abb6201e6dbb6f881dd70 Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Do not access QObject API before its private data is initialized.Milian Wolff2014-02-061-0/+4
| | | | | | | | | | | | Inside the ctor of the private data, the QObject has not yet been associated with the data. Thus, accessing it indirectly i.e. to setup private signal/slot connections, will trigger crashes. Now we delay accessing this API and call an init() function manually in the parent QObject-inheriting class. Change-Id: I2c3ce7335c54d42af6bce87de867ee0ef197efc6 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Use QObjectPrivate instead of dedicated d-ptrKurt Pattyn2014-02-051-5/+2
| | | | | Change-Id: I3f69a2b0ca81e1e003200bb8e0a337b9532e64a0 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Adapt isValid to only return true when socket is in connected stateKurt Pattyn2014-02-011-1/+2
| | | | | | | | Changed isValid() to only return true when the socket is also in connected state. Also updated the documentation. Change-Id: Id80dbc1f28c82bef19984c5ed7b34a7d474ee011 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Remove socketOption functionalityKurt Pattyn2014-02-011-20/+0
| | | | | | | | | | Removed the setSocketOption() and socketOption(0 methods as they are not really relevant for web sockets. Also, internally for the underlying real socket the LowDelayOption and KeepAliveOption are already set. If ever needed, these methods can be added later. Change-Id: Ibfa279990c5277970eaa2dbc2dd3a7d0cce7154e Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Update documentationKurt Pattyn2014-02-011-0/+6
| | | | | | | | Clarified which versions are supported and that subprotocols and extensions are not supported. Fixed some typos. Change-Id: I99ef2fbbf74c287bea7d1b7a07881bf0542135ff Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Removed unsupported functionalityKurt Pattyn2014-02-011-18/+0
| | | | | | | | | | Removed subprotocol and extension getter functionality, as this is currently not supported by QtWebSockets. I left the backend implementation intact (in the _p files), for future reference. Change-Id: Ia00739f6f225cd557ceb10b40c83fc81d98aae0b Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com> Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Rename write methodsKurt Pattyn2014-01-201-4/+8
| | | | | | | | | Renamed the write methods to sendTextMessage and sendBinaryMessage respectively. This makes the code more readable. Change-Id: Ie49abf07a37f54c84bd01c5c788d2e42b28bcfdd Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Remove dubious functionsKurt Pattyn2014-01-201-33/+0
| | | | | Change-Id: Ida5c46e3e42685f5e78f2aee657d12af62286810 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Fix docs after adding const refsFrederik Gladhorn2014-01-171-5/+5
| | | | | Change-Id: I9fc1d996584c1136efca4412fe76c570cc4201ec Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Remove doc reference to non-existent functionLaszlo Agocs2014-01-171-1/+0
| | | | | Change-Id: I309104e808cd6749d8f9430fcbcf170c78056730 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Limit line length to 100 characters.Kurt Pattyn2014-01-121-44/+86
| | | | | Change-Id: I9da963570b174b9a5a33e65cf144402677b4bab5 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Remove waitXXX() methods from websocketsKurt Pattyn2014-01-111-38/+0
| | | | | | | | | | | | | The QWebSocketServer::waitForNewConnection() was just calling QTcpServer::waitForNewConnection(), which was not correct because a connection is only complete when the handshake succeeds. Waiting for the handshake to complete would need a separate thread for the handshake handling code, which would complicate the code a lot. It was decided to leave out all waitXXX() methods from the module, as it is easier to add this functionality later, then to remove it. Change-Id: I778bae45b67f81e151ad2362f772c75e9f537ff0 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add clarification in documentationKurt Pattyn2014-01-041-0/+5
| | | | | Change-Id: Ib616c4c932cb2797036d2d821af7726fcfe2f877 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>