From 762b5f09a61f1f58c0ab7365bf5e826438421c12 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 17 Jul 2020 17:51:16 +1000 Subject: wasm: fix network headers logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-85083 Pick-to: 5.15 Change-Id: Iaf0f3365ee20fe257f3edac0e1105bdfcc5ba0da Reviewed-by: Morten Johan Sørvig --- src/network/access/qnetworkreplywasmimpl.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index 4dfdd99543..c2e66fea5b 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -218,13 +218,15 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() QList headersData = request.rawHeaderList(); int arrayLength = getArraySize(headersData.count()); + const char* customHeaders[arrayLength]; if (headersData.count() > 0) { - const char* customHeaders[arrayLength]; int i = 0; - for (i; i < headersData.count(); i++) { - customHeaders[i] = headersData[i].constData(); - customHeaders[i + 1] = request.rawHeader(headersData[i]).constData(); + for (int j = 0; j < headersData.count(); j++) { + customHeaders[i] = headersData[j].constData(); + i += 1; + customHeaders[i] = request.rawHeader(headersData[j]).constData(); + i += 1; } customHeaders[i] = nullptr; attr.requestHeaders = customHeaders; @@ -370,8 +372,8 @@ void QNetworkReplyWasmImplPrivate::headersReceived(const QByteArray &buffer) for (int i = 0; i < headers.size(); i++) { if (headers.at(i).contains(':')) { // headers include final \x00, so skip - QByteArray headerName = headers.at(i).split(': ').at(0).trimmed(); - QByteArray headersValue = headers.at(i).split(': ').at(1).trimmed(); + QByteArray headerName = headers.at(i).split(':').at(0).trimmed(); + QByteArray headersValue = headers.at(i).split(':').at(1).trimmed(); if (headerName.isEmpty() || headersValue.isEmpty()) continue; -- cgit v1.2.3