diff options
author | Lena Biliaieva <lena.biliaieva@qt.io> | 2024-01-09 01:10:37 +0100 |
---|---|---|
committer | Lena Biliaieva <lena.biliaieva@qt.io> | 2024-02-07 04:44:24 +0100 |
commit | 9743447b30f5f3b61c5716598d7ef9a89edf8d64 (patch) | |
tree | d509c5255e28ff3ad6fc1821e03d9a5b4498bfda | |
parent | 43f54d75c4ef3321f798bd7e296b5cde7dc38ed7 (diff) |
Use QHttpHeaders in QWebSocketHandshakeRequest
QWebSocketHandshakeRequest::headers() method is changed to return QHttpHeaders.
Task-number: QTBUG-120133
Change-Id: I4160512161840a675057daf34534a34cda19bc4d
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 6 | ||||
-rw-r--r-- | src/websockets/qwebsockethandshakerequest.cpp | 2 | ||||
-rw-r--r-- | src/websockets/qwebsockethandshakerequest_p.h | 3 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 83455d9..21241a1 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -360,9 +360,9 @@ QWebSocket *QWebSocketPrivate::upgradeFrom(QTcpSocket *pTcpSocket, QWebSocket *pWebSocket = new QWebSocket(pTcpSocket, response.acceptedVersion(), parent); if (Q_LIKELY(pWebSocket)) { QNetworkRequest netRequest(request.requestUrl()); - const auto headers = request.headers(); - for (auto it = headers.begin(), end = headers.end(); it != end; ++it) - netRequest.setRawHeader(it->first, it->second); + const auto headers = request.headers().toListOfPairs(); + for (const auto &field : headers) + netRequest.setRawHeader(field.first, field.second); #ifndef QT_NO_SSL if (QSslSocket *sslSock = qobject_cast<QSslSocket *>(pTcpSocket)) pWebSocket->setSslConfiguration(sslSock->sslConfiguration()); diff --git a/src/websockets/qwebsockethandshakerequest.cpp b/src/websockets/qwebsockethandshakerequest.cpp index 59f215b..7888d87 100644 --- a/src/websockets/qwebsockethandshakerequest.cpp +++ b/src/websockets/qwebsockethandshakerequest.cpp @@ -83,7 +83,7 @@ bool QWebSocketHandshakeRequest::isValid() const /*! \internal */ -QList<QPair<QByteArray, QByteArray>> QWebSocketHandshakeRequest::headers() const +QHttpHeaders QWebSocketHandshakeRequest::headers() const { return m_parser.headers(); } diff --git a/src/websockets/qwebsockethandshakerequest_p.h b/src/websockets/qwebsockethandshakerequest_p.h index a183d77..659bd9f 100644 --- a/src/websockets/qwebsockethandshakerequest_p.h +++ b/src/websockets/qwebsockethandshakerequest_p.h @@ -19,6 +19,7 @@ #include <QtCore/QString> #include <QtCore/QUrl> #include <QtNetwork/private/qhttpheaderparser_p.h> +#include <QtNetwork/qhttpheaders.h> #include "qwebsocketprotocol.h" @@ -39,7 +40,7 @@ public: int port() const; bool isSecure() const; bool isValid() const; - QList<QPair<QByteArray, QByteArray>> headers() const; + QHttpHeaders headers() const; bool hasHeader(const QByteArray &name) const; QList<QWebSocketProtocol::Version> versions() const; QString key() const; |