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.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 61cc2f7038b..f680950701c 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -138,6 +138,28 @@ static QHash<QByteArray, QByteArray> parseHttpOptionHeader(QByteArrayView header
}
}
+// If the user specified CustomOperation we try to remap the operation to a known
+// operation. This is useful because we treat the operations differently,
+// ie for caching or redirection
+static auto remapCustom(QNetworkAccessManager::Operation operation, const QNetworkRequest &req)
+{
+ if (operation == QNetworkAccessManager::CustomOperation) {
+ const QByteArray customVerb = req.attribute(QNetworkRequest::CustomVerbAttribute)
+ .toByteArray();
+ if (customVerb.compare("get", Qt::CaseInsensitive) == 0)
+ return QNetworkAccessManager::GetOperation;
+ if (customVerb.compare("head", Qt::CaseInsensitive) == 0)
+ return QNetworkAccessManager::HeadOperation;
+ if (customVerb.compare("delete", Qt::CaseInsensitive) == 0)
+ return QNetworkAccessManager::DeleteOperation;
+ if (customVerb.compare("put", Qt::CaseInsensitive) == 0)
+ return QNetworkAccessManager::PutOperation;
+ if (customVerb.compare("post", Qt::CaseInsensitive) == 0)
+ return QNetworkAccessManager::PostOperation;
+ }
+ return operation;
+}
+
QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manager,
const QNetworkRequest& request,
QNetworkAccessManager::Operation& operation,
@@ -150,7 +172,7 @@ QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manage
d->managerPrivate = manager->d_func();
d->request = request;
d->originalRequest = request;
- d->operation = operation;
+ d->operation = remapCustom(operation, request);
d->outgoingData = outgoingData;
d->url = request.url();
#ifndef QT_NO_SSL
@@ -636,12 +658,8 @@ void QNetworkReplyHttpImplPrivate::maybeDropUploadDevice(const QNetworkRequest &
case QNetworkAccessManager::CustomOperation: {
const QByteArray customVerb = newHttpRequest.attribute(QNetworkRequest::CustomVerbAttribute)
.toByteArray();
- if (customVerb.compare("get", Qt::CaseInsensitive) != 0
- && customVerb.compare("head", Qt::CaseInsensitive) != 0
- && customVerb.compare("connect", Qt::CaseInsensitive) != 0
- && customVerb.compare("delete", Qt::CaseInsensitive) != 0) {
+ if (customVerb.compare("connect", Qt::CaseInsensitive) != 0)
return true; // Trust user => content-length 0 is presumably okay!
- }
// else:
[[fallthrough]];
}