summaryrefslogtreecommitdiff
path: root/src/websockets/qwebsocket_p.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use the proper protocol namesSze Howe Koh2014-04-091-2/+2
| | | | | | | | - "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>
* fix compilation with QT_NO_NETWORKPROXYMaurice Kalinowski2014-03-181-1/+4
| | | | | Change-Id: Ice7ad51cbbde0ef2459642309c32dd392463754d Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* fix typo in macroMaurice Kalinowski2014-03-171-1/+1
| | | | | | Change-Id: Ib302db81e0667d0c89c1da8611639db0811ff9f3 Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Return correct error string for known socket errorsKurt Pattyn2014-03-121-1/+1
| | | | | | Task-number: QTBUG-37228 Change-Id: I246b858694ea456bce9a0fc4ac963a83502fd058 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-15/+32
| | | | | | | | | 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>
* Fix multiple emission of received signalsKurt Pattyn2014-02-151-1/+1
| | | | | | Task-number: QTBUG-36762 Change-Id: I239bdd06252fb90056a687ace8540bb91b0055a1 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Check on newline characters in origin and urlsKurt Pattyn2014-02-111-3/+43
| | | | | | | | | | 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>
* Connect sslErrors signal when a secure connection is establishedKurt Pattyn2014-02-071-0/+4
| | | | | | Task-number: QTBUG-36676 Change-Id: Ia93751e5a972adf6434b0d749376e2a8c0619514 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Do not double-delete the TCP socket of a QWebSocket.Milian Wolff2014-02-061-2/+2
| | | | | | | | | | | | | The socket is put into an owning QScopedPointer. But if its also put into the QObject parent-child chain, it will get deleted when the QWebSocket is destroyed. In the dtor of the QWebSocketPrivate class m_pSocket will thus already be destroyed and thus be a dangling pointer. This crashed the QWebSocketServer test reliably for me on exit. Change-Id: I7f06e933bfed832e66b943542c351cde639c9465 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Fix assertion when encountering invalid header line.Milian Wolff2014-02-061-1/+3
| | | | | | | | | | | | | The server test sets an empty identifier which results in a headerLine containing "Server: ". The split then yields a list with a single entry ("Server"). Calling [1] on it asserts then. QFATAL : tst_QWebSocketServer::tst_connectivity() ASSERT failure in QList<T>::operator[]: "index out of range", file /ssd/milian/projects/compiled/qt5/include/QtCore/qlist.h, line 476 Change-Id: I3e5c4750b304b2a4a5669a39e2d65a6b3e4e99cf Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Do not access QObject API before its private data is initialized.Milian Wolff2014-02-061-3/+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-55/+57
| | | | | Change-Id: I3f69a2b0ca81e1e003200bb8e0a337b9532e64a0 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Allow writes only when socket is in connected stateKurt Pattyn2014-02-011-1/+1
| | | | | Change-Id: I3e265ccba334301444611a8013568ba52cca5bcd 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>
* Set default error and errorstringKurt Pattyn2014-02-011-2/+2
| | | | | | | Set the default error and error string to match those of QAbstractSocket. Change-Id: I96277ecda1f56da4de7509a22bcab86df8064e7c Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Locally cache read buffer size and pause modeKurt Pattyn2014-02-011-10/+14
| | | | | | | | | When calling setReadBufferSize() and setPauseMode(), the internal socket is not yet created. So we cache these values and apply them when the internal socket is created. Change-Id: I4299232342438c7a6c52fa8ea4a95461b3f85ebf Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Add TODOs for improvementsKurt Pattyn2014-02-011-0/+2
| | | | | Change-Id: Ifc8cef479147de9fdd9c382ff09be21056cb3e68 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Cleanup inline commentsKurt Pattyn2014-02-011-3/+2
| | | | | Change-Id: I8d96bb2b5c1cf211de50939dc2141572750a4b70 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.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>
* Rename write methodsKurt Pattyn2014-01-201-2/+2
| | | | | | | | | 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-23/+0
| | | | | Change-Id: Ida5c46e3e42685f5e78f2aee657d12af62286810 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Rename enumerations to comply with Qt styleKurt Pattyn2014-01-181-8/+8
| | | | | Change-Id: Id72fe27cec606e7f02b8e9ac1d0d763890e86a95 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Use QString() instead of QStringLiteral("")Frederik Gladhorn2014-01-181-8/+8
| | | | | | | | | | And do the same for QByteArray. Instantiating the default constructor uses QArrayData::sharedNull() for the d-pointer which is the cheapest constructor in memory and instructions. Change-Id: I1ceaafbc0c0cb1ccc5690edba89ea1100f30b3cd Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* one if (m_mustMask) is enoughFrederik Gladhorn2014-01-181-4/+4
| | | | | Change-Id: I6cb89b981b70f10510319bfb51b77874e2a4d85a Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add a few more const refsFrederik Gladhorn2014-01-181-9/+9
| | | | | | | | | In case of processPing we need to make a copy that potentially detaches when masking is requested, but pings are < 125 bytes. Before this code would copy the byte array in the same way much earlier. Change-Id: If0592bb4b508eeb11fdbf05c4bb98b9679ed0549 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Fix warningFrederik Gladhorn2014-01-181-1/+2
| | | | | | | | | | | warning: ignoring return value of 'qint64 QWebSocketPrivate::writeFrame(const QByteArray&)', declared with attribute warn_unused_result [-Wunused-result] For pings the result is not relevant since they are one frame only. Change-Id: Iaf958e3e1a333f8d3c0b0f9ba56f7ab58e4900f9 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Make sure that the random generator is initialized in all code pathsFrederik Gladhorn2014-01-171-3/+11
| | | | | Change-Id: Ice4826e7670cffa791250a95387ac1121ddc4089 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Limit line length to 100 characters.Kurt Pattyn2014-01-121-50/+96
| | | | | Change-Id: I9da963570b174b9a5a33e65cf144402677b4bab5 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Replace emit by Q_EMITKurt Pattyn2014-01-111-4/+4
| | | | | Change-Id: I8543a74a9b3c8c1b45d9e0e12223072b6637199b Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Remove waitXXX() methods from websocketsKurt Pattyn2014-01-111-22/+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>
* Use new connect syntax in a few placesFrederik Gladhorn2014-01-091-16/+18
| | | | | Change-Id: Iff0bd801a2dc4cce9b867e9a83320d0f9a716ab3 Reviewed-by: Steven Ceuppens <steven.ceuppens@icloud.com>
* Adapt to Qt coding styleKurt Pattyn2014-01-041-125/+64
| | | | | Change-Id: I137ac180b19228e0a5683e21ca87e3fe2db9f97b Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add limitation to write() methodsKurt Pattyn2013-12-271-2/+9
| | | | | Change-Id: I5e1176711885ff698b9c05034785adc9a0612ccc Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add optimizationsKurt Pattyn2013-12-231-83/+94
| | | | | Change-Id: Icd293f832e2d7a6272d4953c1994065d16222375 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Cleanup code to comply with Qt styleKurt Pattyn2013-12-101-344/+226
| | | | | | | | | | | | | | - Correct placement of curly braces - Remove commented-out code - Remove superfluous qDebug statements - Add missing QT_BEGIN_NAMESPACE declarations - Add move semantics - Add cleanup handling to QWebSocketServerPrivate - Add error handling to handshake response, QWebSocketServerPrivate, QWebSocketServer, dataprocessor Change-Id: I0690dc2c444fd6fc0db974d1459bf41bd8c31d40 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Change open method so that a web socket can be reopenedKurt Pattyn2013-11-181-13/+21
| | | | | Change-Id: I1c7059a8e581ce5179c00f187b03f59fbed63ba6 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add close code and close reason getter functionsKurt Pattyn2013-11-171-0/+20
| | | | | Change-Id: I4eeab1521054e4f4921d25c6a990eeb7486443cb Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add sslEchoClient and sslEchoServer examplesKurt Pattyn2013-11-061-1/+2
| | | | | | | Add license headers Change-Id: Ied74cb3db6ceed6c3f361e4afac860a7a3fb7676 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Sanitize include directivesKurt Pattyn2013-11-061-0/+1
| | | | | Change-Id: I510e5e8f263d3ea08dd3d623b054d06b2911c6d6 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add QWebSocketConfiguration to pre-cache socket settingsKurt Pattyn2013-11-041-59/+80
| | | | | Change-Id: Ibff22b277b89379dc31b0b7a8a02547e12bff58e Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Change masking to octet based processingKurt Pattyn2013-11-031-1/+3
| | | | | Change-Id: I1b450bf35760e8a5157cb1013f4668815640be5d Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Move non-public methods from websocketprotocol to private headerKurt Pattyn2013-11-021-0/+1
| | | | | | | Add bigendian conversion of masks to unit tests Change-Id: I3f23fb62aac1c6d06e5fafb1bd4bc47cc03765ce Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Move Q_AUTOTEST_EXPORT in front of streaming operatorKurt Pattyn2013-11-021-1/+1
| | | | | Change-Id: I24d336e960038dea235b371449b5a25ca86a7c93 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add null pointer checksKurt Pattyn2013-11-011-167/+274
| | | | | Change-Id: I3582e4ebc6aa275a10dd03b9189cafdc72dc236f Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add correct license headersKurt Pattyn2013-11-011-18/+40
| | | | | Change-Id: I789cd780697aedbca7a90a5991df00b2c7e9ec98 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Add functionality to ignore ssl errorsKurt Pattyn2013-11-011-4/+37
| | | | | Change-Id: I81248b9af104c0b3d37c9cfcef250a102f4b1d32 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Implement of secure web socketsKurt Pattyn2013-10-311-4/+65
| | | | | Change-Id: I1f96d5e4e327eae211fd6b458168e1f7607e2dcf Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
* Replaced getter methods of HandshakeResponse to be in line with QtKurt Pattyn2013-10-141-3/+3
| | | | | Change-Id: I23d9e75413c04a8a2f43ea0b940a0bab33d8d8de Reviewed-by: Steven Ceuppens <steven.ceuppens@icloud.com>
* Renamed getters in HandshakeRequest to comply with QtKurt Pattyn2013-10-131-3/+3
| | | | | | | Renamed all getXXX() methods by XXX() methods. Change-Id: I54f52eb5dfc7342b7aecafb3ec65aa54e7b20d13 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>