我想要移除我的GET请求中默认添加的'Authorization: '头部。QT会自动添加它。
请求示例 -
GET https://mywebsiteurl.com/remote.php/webdav/3.txt HTTP/1.1
Authorization: Basic Og== User-Agent: Mozilla/5.0 (Linux) myapp/1.2.1
Connection: Keep-Alive Accept-Encoding: gzip, deflate Accept-Language: en-US,*
代码示例 -
请求示例 -
GET https://mywebsiteurl.com/remote.php/webdav/3.txt HTTP/1.1
Authorization: Basic Og== User-Agent: Mozilla/5.0 (Linux) myapp/1.2.1
Connection: Keep-Alive Accept-Encoding: gzip, deflate Accept-Language: en-US,*
代码示例 -
QNetworkAccessManager* mgr = new QNetworkAccessManager();
QNetworkRequest req;
req.setUrl(QUrl("sampleURL") );
mgr->get(req);
没有授权头的结果如下:
GET https://mywebsiteurl.com/remote.php/webdav/3.txt HTTP/1.1
User-Agent: Mozilla/5.0 (Linux) myapp/1.2.1
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: en-US,*
可以使用像setHeader、setRawHeader这样的API,但没有完全删除标头的方法。