summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-01 12:54:35 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-01 13:05:22 +0100
commitaf5712d929295bc88ddc2c85754da59dbab9a8eb (patch)
treeaf6cc45e5787b412d76349399a66279cb50ec955
parent7c3f7183080d378a4c3b1c0ed5b12d137f2a2f40 (diff)
downloadqtwebsockets-af5712d929295bc88ddc2c85754da59dbab9a8eb.tar.gz
Fix CMake Unity (Jumbo) builds
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>
-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 dfb06ee..e5d0698 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -41,8 +41,6 @@ using namespace Qt::StringLiterals;
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 f29b40a..836b38b 100644
--- a/src/websockets/qwebsocket_p.h
+++ b/src/websockets/qwebsocket_p.h
@@ -76,6 +76,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());