mirror of
https://github.com/leozide/leocad
synced 2024-12-25 21:58:23 +01:00
Merge pull request #962 from cambrialas/feature_http_redirect
Enable HTTP redirection on lcHttpManager requests
This commit is contained in:
commit
7fd23dab4f
1 changed files with 14 additions and 2 deletions
|
@ -22,10 +22,12 @@ void lcHttpReply::run()
|
||||||
static_assert(sizeof(wchar_t) == sizeof(QChar), "Character size mismatch");
|
static_assert(sizeof(wchar_t) == sizeof(QChar), "Character size mismatch");
|
||||||
|
|
||||||
Session = InternetOpen(L"LeoCAD", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
Session = InternetOpen(L"LeoCAD", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
||||||
|
|
||||||
if (!Session)
|
if (!Session)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Request = InternetOpenUrl(Session, (WCHAR*)mURL.data(), NULL, 0, 0, 0);
|
Request = InternetOpenUrl(Session, (WCHAR*)mURL.data(), NULL, 0, INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP, 0);
|
||||||
|
|
||||||
if (!Request)
|
if (!Request)
|
||||||
{
|
{
|
||||||
InternetCloseHandle(Session);
|
InternetCloseHandle(Session);
|
||||||
|
@ -81,7 +83,17 @@ lcHttpManager::lcHttpManager(QObject* Owner)
|
||||||
|
|
||||||
lcHttpReply* lcHttpManager::lcHttpManager::DownloadFile(const QString& Url)
|
lcHttpReply* lcHttpManager::lcHttpManager::DownloadFile(const QString& Url)
|
||||||
{
|
{
|
||||||
return (lcHttpReply*)get(QNetworkRequest(QUrl(Url)));
|
QNetworkRequest Request = QNetworkRequest(QUrl(Url));
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) // default changed in Qt6
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
|
||||||
|
Request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||||
|
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||||
|
Request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (lcHttpReply*)get(Request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcHttpManager::Finished(QNetworkReply* Reply)
|
void lcHttpManager::Finished(QNetworkReply* Reply)
|
||||||
|
|
Loading…
Reference in a new issue