Showing the changes to libraries/script-engine/src/ScriptCache.cpp (1 of 1 file). Show all
Unified · Split
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <QCoreApplication> |
| 13 | 13 | #include <QEventLoop> |
| 14 | 14 | #include <QNetworkAccessManager> |
| 15 | +#include <QNetworkConfiguration> | |
| 15 | 16 | #include <QNetworkReply> |
| 16 | 17 | #include <QObject> |
| 17 | 18 | |
| @@ -35,7 +36,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 17 unmodified lines | ||
| 35 | 36 | isPending = true; |
| 36 | 37 | bool alreadyWaiting = _scriptUsers.contains(url); |
| 37 | 38 | _scriptUsers.insert(url, scriptUser); |
| 38 | − | |
| 39 | + | |
| 39 | 40 | if (alreadyWaiting) { |
| 40 | 41 | qCDebug(scriptengine) << "Already downloading script at:" << url.toString(); |
| 41 | 42 | } else { |
| @@ -43,7 +44,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 1 unmodified line | ||
| 43 | 44 | QNetworkRequest networkRequest = QNetworkRequest(url); |
| 44 | 45 | networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); |
| 45 | 46 | |
| 46 | − qCDebug(scriptengine) << "Downloading script at:" << url.toString(); | |
| 47 | + qCDebug(scriptengine) << "Downloading script at" << url.toString(); | |
| 47 | 48 | QNetworkReply* reply = networkAccessManager.get(networkRequest); |
| 48 | 49 | connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded); |
| 49 | 50 | } |
| @@ -56,7 +57,7 @@ void ScriptCache::scriptDownloaded() { · 6 unmodified lines | ||
| 56 | 57 | QUrl url = reply->url(); |
| 57 | 58 | QList<ScriptUser*> scriptUsers = _scriptUsers.values(url); |
| 58 | 59 | _scriptUsers.remove(url); |
| 59 | − | |
| 60 | + | |
| 60 | 61 | if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) { |
| 61 | 62 | _scriptCache[url] = reply->readAll(); |
| 62 | 63 | qCDebug(scriptengine) << "Done downloading script at:" << url.toString(); |
| @@ -65,7 +66,9 @@ void ScriptCache::scriptDownloaded() { · 2 unmodified lines | ||
| 65 | 66 | user->scriptContentsAvailable(url, _scriptCache[url]); |
| 66 | 67 | } |
| 67 | 68 | } else { |
| 68 | − qCDebug(scriptengine) << "ERROR Loading file:" << reply->url().toString(); | |
| 69 | + qCWarning(scriptengine) << "Error loading script from URL " << reply->url().toString() | |
| 70 | + << "- HTTP status code is" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() | |
| 71 | + << "and error from QNetworkReply is" << reply->errorString(); | |
| 69 | 72 | foreach(ScriptUser* user, scriptUsers) { |
| 70 | 73 | user->errorInLoadingScript(url); |
| 71 | 74 | } |
| @@ -73,4 +76,4 @@ void ScriptCache::scriptDownloaded() { · 1 unmodified line | ||
| 73 | 76 | reply->deleteLater(); |
| 74 | 77 | } |
| 75 | 78 | |
| 76 | − | |
| 79 | + | |