开发笔记

  • 首页
  • 工具箱
三味线的博客
  1. 首页
  2. Qt
  3. 正文

Qt6 QNetworkRequest ProtocolInvalidOperationError(302)

2021-11-02 951点热度 2人点赞 0条评论

在Qt6.2.1中使用HTTP GET请求时,出现了错误:QNetworkReply::ProtocolInvalidOperationError,但是用postman调用同一接口就是正常的,用Wireshark查看2次请求的header发现,Qt6使用了HTTP/2:

正常的
Qt 6的

需要禁用HTTP/2才能正常请求:

mRequest.setAttribute(QNetworkRequest::Http2AllowedAttribute, false);

该属性描述:

Requests only, type: QMetaType::Bool (default: true) Indicates whether the QNetworkAccessManager code is allowed to use HTTP/2 with this request. This applies to SSL requests or 'cleartext' HTTP/2.
标签: Qt Qt6
最后更新:2021-11-02

三味线

不吃咸鱼的喵

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

Captcha Code

COPYRIGHT © 2022 voidcat.cn. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

蜀ICP备18010095号-1