1
0
Fork 0
forked from len0rd/rockbox

Add support file:// URLs in HttpGet.

QNetworkAccessManager can handle file:// URLs without additional work. Make
HttpGet aware of that so you can now also use it to retrieve file:// URLs. Add
a unit test for it as well.

Change-Id: If64b57453460b70bca9e5b0c725bb78344617bcd
This commit is contained in:
Dominik Riebeling 2015-12-18 23:05:13 +01:00
parent 4627d4b56e
commit d24a9ea3b2
2 changed files with 26 additions and 2 deletions

View file

@ -17,7 +17,6 @@
****************************************************************************/
#include <QtNetwork>
#include <QtDebug>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
@ -155,7 +154,10 @@ void HttpGet::requestFinished(QNetworkReply* reply)
startRequest(url);
return;
}
else if(m_lastStatusCode == 200) {
else if(m_lastStatusCode == 200 ||
(reply->url().isLocalFile() && reply->error() == 0)) {
// callers might not be aware if the request is file:// so fake 200.
m_lastStatusCode = 200;
m_data = reply->readAll();
if(m_outputFile && m_outputFile->open(QIODevice::WriteOnly)) {
m_outputFile->write(m_data);