From e2a13299101d27800d3d1d88b91635e66d52d5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 19 Apr 2022 16:30:14 +0200 Subject: QHttp: Don't reorder content-length header for no reason If the user supplied a content-length, and we also know the size of the payload then we would set the content-length again, which is a remove + add on a QList. This is completely avoidable if we are setting the same size anyway. Fixes: QTBUG-102495 Change-Id: If62739cadb453dbda4c21e858ba3a17baaf71fb4 Reviewed-by: Edward Welbourne --- src/network/access/qhttpnetworkconnection.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/network/access/qhttpnetworkconnection.cpp') diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index f8ef05a561..3f7442b189 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -265,8 +265,9 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) const qint64 contentLength = request.contentLength(); const qint64 uploadDeviceSize = uploadByteDevice->size(); if (contentLength != -1 && uploadDeviceSize != -1) { - // both values known, take the smaller one. - request.setContentLength(qMin(uploadDeviceSize, contentLength)); + // Both values known: use the smaller one. + if (uploadDeviceSize < contentLength) + request.setContentLength(uploadDeviceSize); } else if (contentLength == -1 && uploadDeviceSize != -1) { // content length not supplied by user, but the upload device knows it request.setContentLength(uploadDeviceSize); -- cgit v1.2.3