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 <edward.welbourne@qt.io>
This commit is contained in:
parent
3962a194d9
commit
e2a1329910
@ -265,8 +265,9 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair)
|
|||||||
const qint64 contentLength = request.contentLength();
|
const qint64 contentLength = request.contentLength();
|
||||||
const qint64 uploadDeviceSize = uploadByteDevice->size();
|
const qint64 uploadDeviceSize = uploadByteDevice->size();
|
||||||
if (contentLength != -1 && uploadDeviceSize != -1) {
|
if (contentLength != -1 && uploadDeviceSize != -1) {
|
||||||
// both values known, take the smaller one.
|
// Both values known: use the smaller one.
|
||||||
request.setContentLength(qMin(uploadDeviceSize, contentLength));
|
if (uploadDeviceSize < contentLength)
|
||||||
|
request.setContentLength(uploadDeviceSize);
|
||||||
} else if (contentLength == -1 && uploadDeviceSize != -1) {
|
} else if (contentLength == -1 && uploadDeviceSize != -1) {
|
||||||
// content length not supplied by user, but the upload device knows it
|
// content length not supplied by user, but the upload device knows it
|
||||||
request.setContentLength(uploadDeviceSize);
|
request.setContentLength(uploadDeviceSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user