mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2024-11-22 09:15:18 +00:00
(Hopefully) fixed #1
[Setup] Fixed: Sailfin would get into an infinite loop while trying to resolve certain urls.
This commit is contained in:
parent
d6f0881e5e
commit
7bb1fdddba
|
@ -97,8 +97,8 @@ Dialog {
|
||||||
model: userModel
|
model: userModel
|
||||||
delegate: UserGridDelegate {
|
delegate: UserGridDelegate {
|
||||||
name: model.name
|
name: model.name
|
||||||
image: model.primaryImageTag ? "%1/Users/%2/Images/Primary?tag=%3".arg(ApiClient.baseUrl).arg(model.id).arg(model.primaryImageTag) : null
|
image: model.primaryImageTag ? "%1/Users/%2/Images/Primary?tag=%3".arg(ApiClient.baseUrl).arg(model.id).arg(model.primaryImageTag) : ""
|
||||||
highlighted: model.name == username.text
|
highlighted: model.name === username.text
|
||||||
onClicked: {
|
onClicked: {
|
||||||
username.text = model.name
|
username.text = model.name
|
||||||
password.focus = true
|
password.focus = true
|
||||||
|
|
|
@ -126,31 +126,25 @@ void ApiClient::setupConnection() {
|
||||||
// First detect redirects:
|
// First detect redirects:
|
||||||
// Note that this is done without calling JellyfinApiClient::get since that automatically includes the base_url,
|
// Note that this is done without calling JellyfinApiClient::get since that automatically includes the base_url,
|
||||||
// which is something we want to avoid here.
|
// which is something we want to avoid here.
|
||||||
QNetworkReply *rep = m_naManager.get(QNetworkRequest(m_baseUrl));
|
QNetworkRequest req = QNetworkRequest(m_baseUrl);
|
||||||
|
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
|
QNetworkReply *rep = m_naManager.get(req);
|
||||||
connect(rep, &QNetworkReply::finished, this, [rep, this](){
|
connect(rep, &QNetworkReply::finished, this, [rep, this](){
|
||||||
int status = statusCode(rep);
|
int status = statusCode(rep);
|
||||||
qDebug() << status;
|
qDebug() << status;
|
||||||
|
|
||||||
// Check if redirect
|
QString newUrl = rep->url().toString();
|
||||||
if (status >= 300 && status < 400) {
|
// If the server wants to redirect us to their web interface, we have to chop the last part of the url off.
|
||||||
QString location = QString::fromUtf8(rep->rawHeader("location"));
|
|
||||||
qInfo() << "Redirect from " << this->m_baseUrl << " to " << location;
|
|
||||||
QUrl base = QUrl(m_baseUrl);
|
|
||||||
QString newUrl = base.resolved(QUrl(location)).toString();
|
|
||||||
// If the url wants to redirect us to their web interface, we have to chop the last part of.
|
|
||||||
if (newUrl.endsWith("/web/index.html")) {
|
if (newUrl.endsWith("/web/index.html")) {
|
||||||
newUrl.chop(QString("/web/index.html").size());
|
newUrl.chop(QString("/web/index.html").size());
|
||||||
this->setBaseUrl(newUrl);
|
this->setBaseUrl(newUrl);
|
||||||
getBrandingConfiguration();
|
|
||||||
} else {
|
|
||||||
this->setBaseUrl(newUrl);
|
|
||||||
setupConnection();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
getBrandingConfiguration();
|
|
||||||
}
|
}
|
||||||
|
this->getBrandingConfiguration();
|
||||||
rep->deleteLater();
|
rep->deleteLater();
|
||||||
});
|
});
|
||||||
|
connect(rep, &QNetworkReply::redirected, this, [req] (const QUrl &url) {
|
||||||
|
qDebug() << "Redirect from " << req.url() << " to " << url;
|
||||||
|
});
|
||||||
setDefaultErrorHandler(rep);
|
setDefaultErrorHandler(rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue