wasm: fix network headers logic

Fixes: QTBUG-85083
Pick-to: 5.15
Change-Id: Iaf0f3365ee20fe257f3edac0e1105bdfcc5ba0da
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Lorn Potter 2020-07-17 17:51:16 +10:00
parent d782df4861
commit 762b5f09a6

View File

@ -218,13 +218,15 @@ void QNetworkReplyWasmImplPrivate::doSendRequest()
QList<QByteArray> 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;