QNetworkReply::NetworkError(ProtocolInvalidOperationError) 这是什么以及如何解决?
QNetworkReply::NetworkError(ProtocolInvalidOperationError) what is it and how to fix it?
我正在尝试向网页发出 POST 请求,但我在以下代码中遇到错误:
void WebViewModel::sendPOST(QString url)
{
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QByteArray postData;
postData.append("");
manager_->post(request, postData);
connect(manager_, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinishedSlot(QNetworkReply *)));
}
void WebViewModel::replyFinishedSlot(QNetworkReply *reply)
{
QUrl webReportsUrl("http://...");
if(reply->error()) <-- **Here I got NetworkReply::NetworkError(ProtocolInvalidOperationError)**
{
qDebug() << "Error: ";
qDebug() << reply->errorString();
qDebug() << QNetworkReply::NetworkError(reply->error());
qDebug() << reply->error();
}
else
{
qDebug() << "no error";
}
reply->deleteLater();
}
这是 302 错误,QT 文档中的描述如下:
the requested operation is invalid for this protocol
如何修复?
我正在尝试向网页发出 POST 请求,但我在以下代码中遇到错误:
void WebViewModel::sendPOST(QString url)
{
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QByteArray postData;
postData.append("");
manager_->post(request, postData);
connect(manager_, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinishedSlot(QNetworkReply *)));
}
void WebViewModel::replyFinishedSlot(QNetworkReply *reply)
{
QUrl webReportsUrl("http://...");
if(reply->error()) <-- **Here I got NetworkReply::NetworkError(ProtocolInvalidOperationError)**
{
qDebug() << "Error: ";
qDebug() << reply->errorString();
qDebug() << QNetworkReply::NetworkError(reply->error());
qDebug() << reply->error();
}
else
{
qDebug() << "no error";
}
reply->deleteLater();
}
这是 302 错误,QT 文档中的描述如下:
the requested operation is invalid for this protocol
如何修复?