Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
KPublicTransport
Commits
8c5cecce
Commit
8c5cecce
authored
Sep 04, 2021
by
Volker Krause
Browse files
Deal with broken feed URLs in GBFS version responses
Yes, that occurs in the wild...
parent
506f777c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/gbfs/gbfsjob.cpp
View file @
8c5cecce
...
...
@@ -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
);
...
...
src/lib/gbfs/gbfsjob.h
View file @
8c5cecce
...
...
@@ -84,6 +84,7 @@ private:
QNetworkAccessManager
*
m_nam
=
nullptr
;
GBFSService
m_service
;
QUrl
m_previousDiscoveryUrl
;
GBFSStore
m_store
;
QJsonDocument
m_discoverDoc
;
QJsonDocument
m_versionDoc
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment