summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyhttpimpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qnetworkreplyhttpimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index e591340257..f189f5be20 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -1155,6 +1155,26 @@ void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int htt
redirectRequest = createRedirectRequest(originalRequest, url, maxRedirectsRemaining);
operation = getRedirectOperation(operation, httpStatus);
+ // Clear stale headers, the relevant ones get set again later
+ httpRequest.clearHeaders();
+ if (operation == QNetworkAccessManager::GetOperation
+ || operation == QNetworkAccessManager::HeadOperation) {
+ // possibly changed from not-GET/HEAD to GET/HEAD, make sure to get rid of upload device
+ uploadByteDevice.reset();
+ uploadByteDevicePosition = 0;
+ if (outgoingData) {
+ QObject::disconnect(outgoingData, SIGNAL(readyRead()), q,
+ SLOT(_q_bufferOutgoingData()));
+ QObject::disconnect(outgoingData, SIGNAL(readChannelFinished()), q,
+ SLOT(_q_bufferOutgoingDataFinished()));
+ }
+ outgoingData = nullptr;
+ outgoingDataBuffer.reset();
+ // We need to explicitly unset these headers so they're not reapplied to the httpRequest
+ redirectRequest.setHeader(QNetworkRequest::ContentLengthHeader, QVariant());
+ redirectRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant());
+ }
+
if (const QNetworkCookieJar *const cookieJar = manager->cookieJar()) {
auto cookies = cookieJar->cookiesForUrl(url);
if (!cookies.empty()) {
@@ -1435,6 +1455,9 @@ void QNetworkReplyHttpImplPrivate::resetUploadDataSlot(bool *r)
// Coming from QNonContiguousByteDeviceThreadForwardImpl in HTTP thread
void QNetworkReplyHttpImplPrivate::sentUploadDataSlot(qint64 pos, qint64 amount)
{
+ if (!uploadByteDevice) // uploadByteDevice is no longer available
+ return;
+
if (uploadByteDevicePosition + amount != pos) {
// Sanity check, should not happen.
error(QNetworkReply::UnknownNetworkError, QString());
@@ -1449,6 +1472,9 @@ void QNetworkReplyHttpImplPrivate::wantUploadDataSlot(qint64 maxSize)
{
Q_Q(QNetworkReplyHttpImpl);
+ if (!uploadByteDevice) // uploadByteDevice is no longer available
+ return;
+
// call readPointer
qint64 currentUploadDataLength = 0;
char *data = const_cast<char*>(uploadByteDevice->readPointer(maxSize, currentUploadDataLength));