summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-12 03:00:24 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-12 03:00:24 +0200
commitccd820c0d215db1de3b0b018cfc329da5ac718e2 (patch)
tree929df495b5dd61ffc70b34b6804df0dd4520808d
parent31cfb286aefcd4625d8b41961ac87c592581d839 (diff)
parentbe5236e86e3d188f8adf1f65fd24b2060c0369e8 (diff)
downloadqtwebsockets-ccd820c0d215db1de3b0b018cfc329da5ac718e2.tar.gz
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I258a6e38c9dfb6ac18ffaa5885cf7337aa99e032
-rw-r--r--src/websockets/qwebsocketserver.cpp22
-rw-r--r--src/websockets/qwebsocketserver.h16
-rw-r--r--tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp12
3 files changed, 46 insertions, 4 deletions
diff --git a/src/websockets/qwebsocketserver.cpp b/src/websockets/qwebsocketserver.cpp
index ecd9da8..eafe3fd 100644
--- a/src/websockets/qwebsocketserver.cpp
+++ b/src/websockets/qwebsocketserver.cpp
@@ -353,15 +353,26 @@ int QWebSocketServer::maxPendingConnections() const
}
/*!
+ \fn std::chrono::milliseconds QWebSocketServer::handshakeTimeout() const
Returns the handshake timeout for new connections in milliseconds.
The default is 10 seconds. If a peer uses more time to complete the
handshake their connection is closed.
- \sa setHandshakeTimeout()
+ \sa setHandshakeTimeout(), handshakeTimeoutMS()
\since 5.14
*/
-int QWebSocketServer::handshakeTimeout() const
+
+/*!
+ Returns the handshake timeout for new connections in milliseconds.
+
+ The default is 10 seconds. If a peer uses more time to complete the
+ handshake their connection is closed.
+
+ \sa setHandshakeTimeout(), handshakeTimeout()
+ \since 5.14
+ */
+int QWebSocketServer::handshakeTimeoutMS() const
{
Q_D(const QWebSocketServer);
return d->handshakeTimeout();
@@ -593,15 +604,20 @@ void QWebSocketServer::setMaxPendingConnections(int numConnections)
}
/*!
+ \fn void QWebSocketServer::setHandshakeTimeout(std::chrono::milliseconds msec)
Sets the handshake timeout for new connections to \a msec milliseconds.
By default this is set to 10 seconds. If a peer uses more time to
complete the handshake, their connection is closed. You can pass a
negative value (e.g. -1) to disable the timeout.
- \sa handshakeTimeout()
+ \sa handshakeTimeout(), handshakeTimeoutMS()
\since 5.14
*/
+
+/*!
+ \overload
+*/
void QWebSocketServer::setHandshakeTimeout(int msec)
{
Q_D(QWebSocketServer);
diff --git a/src/websockets/qwebsocketserver.h b/src/websockets/qwebsocketserver.h
index dd06448..ceb9106 100644
--- a/src/websockets/qwebsocketserver.h
+++ b/src/websockets/qwebsocketserver.h
@@ -52,6 +52,10 @@
#include <QtNetwork/QSslError>
#endif
+#if QT_HAS_INCLUDE(<chrono>)
+#include <chrono>
+#endif
+
QT_BEGIN_NAMESPACE
class QTcpSocket;
@@ -86,8 +90,18 @@ public:
void setMaxPendingConnections(int numConnections);
int maxPendingConnections() const;
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_CLANG_QDOC)
+ void setHandshakeTimeout(std::chrono::milliseconds msec)
+ {
+ setHandshakeTimeout(int(msec.count()));
+ }
+ std::chrono::milliseconds handshakeTimeout() const
+ {
+ return std::chrono::milliseconds(handshakeTimeoutMS());
+ }
+#endif
void setHandshakeTimeout(int msec);
- int handshakeTimeout() const;
+ int handshakeTimeoutMS() const;
quint16 serverPort() const;
QHostAddress serverAddress() const;
diff --git a/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp
index 20d7060..c40bb01 100644
--- a/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp
+++ b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp
@@ -294,6 +294,18 @@ void tst_QWebSocketServer::tst_settersAndGetters()
QCOMPARE(sslServer.sslConfiguration(), sslConfiguration);
QVERIFY(sslServer.sslConfiguration() != QSslConfiguration::defaultConfiguration());
#endif
+
+ server.setHandshakeTimeout(64);
+ QCOMPARE(server.handshakeTimeoutMS(), 64);
+#if QT_HAS_INCLUDE(<chrono>)
+ auto expected = std::chrono::milliseconds(64);
+ QCOMPARE(server.handshakeTimeout(), expected);
+
+ expected = std::chrono::milliseconds(242);
+ server.setHandshakeTimeout(expected);
+ QCOMPARE(server.handshakeTimeoutMS(), 242);
+ QCOMPARE(server.handshakeTimeout(), expected);
+#endif
}
void tst_QWebSocketServer::tst_listening()