summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-01 12:54:35 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-01 14:36:08 +0000
commit2c2e94b51f12600c680659a37006f62dcc4d5e5b (patch)
treef51940d647434f60cd30d36e076750e7dab92fc4
parent9f7ae8905296cc198e25ded17ce343d2c5287a0e (diff)
downloadqtwebsockets-2c2e94b51f12600c680659a37006f62dcc4d5e5b.tar.gz
Fix CMake Unity (Jumbo) builds
Move clashing constants to QWebSocketPrivate. Task-number: QTBUG-109394 Change-Id: I6d22f2134683c2fb65b79732b991c7ff05338a8c Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> (cherry picked from commit af5712d929295bc88ddc2c85754da59dbab9a8eb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/websockets/qwebsocket_p.cpp2
-rw-r--r--src/websockets/qwebsocket_p.h6
-rw-r--r--src/websockets/qwebsocketserver_p.cpp11
3 files changed, 9 insertions, 10 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index f08bf3b..9fef0c3 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -37,8 +37,6 @@ QT_BEGIN_NAMESPACE
namespace {
-constexpr int MAX_HEADERLINE_LENGTH = 8 * 1024; // maximum length of a http request header line
-constexpr int MAX_HEADERLINES = 100; // maximum number of http request header lines
constexpr quint64 MAX_OUTGOING_FRAME_SIZE_IN_BYTES = std::numeric_limits<int>::max() - 1;
constexpr quint64 DEFAULT_OUTGOING_FRAME_SIZE_IN_BYTES = 512 * 512 * 2; // default size of a frame when sending a message
diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h
index 08be774..e78970d 100644
--- a/src/websockets/qwebsocket_p.h
+++ b/src/websockets/qwebsocket_p.h
@@ -75,6 +75,12 @@ public:
QWebSocketProtocol::Version version);
~QWebSocketPrivate() override;
+ // both constants are taken from the default settings of Apache
+ // see: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize and
+ // http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfields
+ static constexpr int MAX_HEADERLINE_LENGTH = 8 * 1024; // maximum length of a http request header line
+ static constexpr int MAX_HEADERLINES = 100; // maximum number of http request header lines
+
void init();
void abort();
QAbstractSocket::SocketError error() const;
diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp
index a0afd10..c8a2e87 100644
--- a/src/websockets/qwebsocketserver_p.cpp
+++ b/src/websockets/qwebsocketserver_p.cpp
@@ -21,12 +21,6 @@
QT_BEGIN_NAMESPACE
-//both constants are taken from the default settings of Apache
-//see: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize and
-//http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfields
-const int MAX_HEADERLINE_LENGTH = 8 * 1024; //maximum length of a http request header line
-const int MAX_HEADERLINES = 100; //maximum number of http request header lines
-
/*!
\internal
*/
@@ -455,7 +449,8 @@ void QWebSocketServerPrivate::handshakeReceived()
if (endOfHeaderIndex < 0) {
//then we don't have our header complete yet
//check that no one is trying to exhaust our virtual memory
- const qint64 maxHeaderLength = MAX_HEADERLINE_LENGTH * MAX_HEADERLINES + endOfHeaderMarker.size();
+ const qint64 maxHeaderLength = QWebSocketPrivate::MAX_HEADERLINE_LENGTH
+ * QWebSocketPrivate::MAX_HEADERLINES + endOfHeaderMarker.size();
if (Q_UNLIKELY(byteAvailable > maxHeaderLength)) {
pTcpSocket->close();
setError(QWebSocketProtocol::CloseCodeTooMuchData,
@@ -490,7 +485,7 @@ void QWebSocketServerPrivate::handshakeReceived()
}
QWebSocketHandshakeRequest request(pTcpSocket->peerPort(), isSecure);
- request.readHandshake(header, MAX_HEADERLINE_LENGTH);
+ request.readHandshake(header, QWebSocketPrivate::MAX_HEADERLINE_LENGTH);
if (request.isValid()) {
QWebSocketCorsAuthenticator corsAuthenticator(request.origin());