aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/websockets/qwebsocket_p.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index 21241a1..1553daa 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -334,7 +334,7 @@ QStringList QWebSocketPrivate::requestedSubProtocols() const
{
auto subprotocolsRequestedInRawHeader = [this]() {
QStringList protocols;
- QByteArray rawProtocols = m_request.rawHeader("Sec-WebSocket-Protocol");
+ QByteArrayView rawProtocols = m_request.headers().value("Sec-WebSocket-Protocol");
QLatin1StringView rawProtocolsView(rawProtocols);
const QStringList &optionsProtocols = m_options.subprotocols();
for (auto &&entry : rawProtocolsView.tokenize(u',', Qt::SkipEmptyParts)) {
@@ -360,9 +360,7 @@ 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().toListOfPairs();
- for (const auto &field : headers)
- netRequest.setRawHeader(field.first, field.second);
+ netRequest.setHeaders(request.headers());
#ifndef QT_NO_SSL
if (QSslSocket *sslSock = qobject_cast<QSslSocket *>(pTcpSocket))
pWebSocket->setSslConfiguration(sslSock->sslConfiguration());
@@ -1195,13 +1193,16 @@ void QWebSocketPrivate::processStateChanged(QAbstractSocket::SocketState socketS
m_key = generateKey();
QList<QPair<QString, QString> > headers;
- const auto headerList = m_request.rawHeaderList();
- for (const QByteArray &key : headerList) {
+ const auto h = m_request.headers();
+ for (qsizetype i = 0; i < h.size(); ++i) {
+ const auto name = h.nameAt(i);
+ const auto value = h.valueAt(i);
+
// protocols handled separately below
- if (key.compare("Sec-WebSocket-Protocol", Qt::CaseInsensitive) == 0)
+ if (name.compare("Sec-WebSocket-Protocol", Qt::CaseInsensitive) == 0)
continue;
- headers << qMakePair(QString::fromLatin1(key),
- QString::fromLatin1(m_request.rawHeader(key)));
+ headers << qMakePair(QString::fromLatin1(name),
+ QString::fromLatin1(value));
}
const QStringList subProtocols = requestedSubProtocols();