0

我试图实现QNetworkRequest::UserVerifiedRedirectPolicy,这是我当前的设置,没有使用任何重定向,

auto request = QNetworkRequest(QUrl(url));
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true);
request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
request.setPriority(QNetworkRequest::HighPriority);
request.setRawHeader("User-Agent", "REDIR-TESTS");
request.setRawHeader("Accept-Language", "en,*");
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
request.setSslConfiguration(*net::NetworkManager::instance()->sslConfiguration());

当通过可能的例子时,发现这个问题,Follow redirects in QT5.5 As per OP here, the url redirects in QT5.6+ works just by setting QNetworkRequest::FollowRedirectsAttribute.

根据文档,QT6 的默认重定向策略是NoLessSafeRedirectPolicy并且需要redirected插槽。那么这是否意味着在 QT5.6+ 中重定向会自动工作而不使用QNetworkReply::redirected()插槽?

我找不到任何解释该行为的文档,也找不到一个很好的实现示例,UserVerifiedRedirectPolicy尽管我在这里找到了一个以 QT4 方式实现它QNetworkAccessManager 不处理 HTTP Status Code 308,但如果可能的话,我不想使用 QT4 方式,任何想法?

4

0 回答 0