我正在尝试向我的firebase应用程序发送"PATCH"请求.据我所知,QNetworkManager不支持"Patch"请求.
如何发送"PATCH"请求?
所以我们很清楚,QNetworkAccessManager中没有名为"patch"的方法因此我使用了"sendCustomRequest"而是使用了QBuffer.因为QNetworkManager需要QIODevice对象.
QString destination=""; currentNode.replace(QString("/").append(latestNode),""); destination .append(host) .append(currentNode) .append(".json"); QString jsonString=QString(QString("{").append("\"").append(latestNode).append("\"").append(":").append("\"").append(str).append("\"").append(QString("}"))); QNetworkRequest request(destination); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); qDebug()<open((QBuffer::ReadWrite)); buffer->write(jsonString.toUtf8()); buffer->seek(0); manager->sendCustomRequest(request,"PATCH",buffer); qDebug()<<"posted";