'What's the meaning of QNetworkReply::ProtocolUnknownError?
I use a object of QNetworkAccessManager to post json data to a website.
when handle the reply which is a pointer of QNetworkReply class in the slot function, the value of reply->error() is 301 and the value of reply->errorString() is Error downloading http://www.example.com/query - server replied: Service Unavailable.
I check the documentation of QNetworkReply, the description of this error is:
QNetworkReply::ProtocolUnknownError|301|the Network Access API cannot honor the request because the protocol is not known
and I also known this error is different form the http status 301.
and I have add http:// before the url.
Can someone give some info about this?
Solution 1:[1]
Since it's a 301 status code there's a redirect. In QtNetwork the ProtocolUnknownError is returned for redirects if the resolved URL is invalid[0] or does not use the http/https scheme[1]
Since I do not know what target-URL you get redirected to I cannot say for that this is what the problem is though.
[0] https://github.com/qt/qtbase/blob/5.15/src/network/access/qhttpnetworkconnection.cpp#L546
[1] https://github.com/qt/qtbase/blob/5.15/src/network/access/qhttpnetworkconnection.cpp#L563
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Morten242 |
