Commit 8c5cecce authored by Volker Krause's avatar Volker Krause
Browse files

Deal with broken feed URLs in GBFS version responses

Yes, that occurs in the wild...
parent 506f777c
......@@ -74,11 +74,16 @@ void GBFSJob::discoverFinished(QNetworkReply *reply)
{
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
handleNetworkError(reply);
return;
if (m_previousDiscoveryUrl.isValid()) {
qDebug() << "new version discovery failed, falling back to old one" << reply->errorString();
m_service.discoveryUrl = m_previousDiscoveryUrl;
} else {
handleNetworkError(reply);
return;
}
} else {
m_discoverDoc = QJsonDocument::fromJson(reply->readAll());
}
m_discoverDoc = QJsonDocument::fromJson(reply->readAll());
parseDiscoverData();
}
......@@ -366,6 +371,7 @@ void GBFSJob::parseVersionData(const QJsonDocument &doc)
const auto url = QUrl(bestVersion.value(QLatin1String("url")).toString());
if (!url.isEmpty() && m_service.discoveryUrl != url) {
qDebug() << "found newer version:" << url << m_service.discoveryUrl;
m_previousDiscoveryUrl = m_service.discoveryUrl;
m_service.discoveryUrl = url;
m_state = State::DiscoverRestart;
discoverAndUpdate(m_service);
......
......@@ -84,6 +84,7 @@ private:
QNetworkAccessManager *m_nam = nullptr;
GBFSService m_service;
QUrl m_previousDiscoveryUrl;
GBFSStore m_store;
QJsonDocument m_discoverDoc;
QJsonDocument m_versionDoc;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment