这个问题是对QNetworkAccessManager - 如何发送"PATCH"请求。
QNetworkAccessManager 没有方法
sendCustomRequest(const QNetworkRequest & request, const QByteArray & verb, QHttpMultiPart * multiPart)
我坚持使用Qt 4.8-bb10。我应该怎么做?
我认为您可以通过将多余的部分放入数据中来自己构建多部分请求,如下所示。
抱歉,我无法测试,所以这只是一个粗略的想法。
QUrl url("http://data.mybusiness.com/patches");
QNetworkRequest request(url);
QString boundary("------------------------------------asdfyiuqwer762345");
request.setRawHeader("Content-Type", QByteArray("multipart/form-data; boundary=").append(boundary));
QByteArray data;
data.append("--" + boundary + "rn");
data.append("Content-Disposition: form-data; name="City"rn");
data.append("rn");
data.append("Parisrn");
data.append("--" + boundary + "rn");
data.append("Content-Disposition: form-data; name="Country"rn");
data.append("rn");
data.append("Canadarn");
data.append("--" + boundary + "--rn");
/* Final boundary has extra -- at end */
QBuffer * pBuffer = new QBuffer(pNetworkAccessManager);
pBuffer->setData(data);
QNetworkReply * pReply = pNetworkAccessManager->sendCustomRequest(request, "PATCH", pBuffer);