summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base/httpget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/base/httpget.cpp')
-rw-r--r--rbutil/rbutilqt/base/httpget.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/rbutil/rbutilqt/base/httpget.cpp b/rbutil/rbutilqt/base/httpget.cpp
index e6b9eb4d3c..4b08faf33b 100644
--- a/rbutil/rbutilqt/base/httpget.cpp
+++ b/rbutil/rbutilqt/base/httpget.cpp
@@ -23,6 +23,7 @@
23#include <QNetworkRequest> 23#include <QNetworkRequest>
24 24
25#include "httpget.h" 25#include "httpget.h"
26#include "Logger.h"
26 27
27QString HttpGet::m_globalUserAgent; //< globally set user agent for requests 28QString HttpGet::m_globalUserAgent; //< globally set user agent for requests
28QDir HttpGet::m_globalCache; //< global cach path value for new objects 29QDir HttpGet::m_globalCache; //< global cach path value for new objects
@@ -71,14 +72,14 @@ void HttpGet::setCache(bool c)
71 QString path = m_cachedir.absolutePath(); 72 QString path = m_cachedir.absolutePath();
72 73
73 if(!c || m_cachedir.absolutePath().isEmpty()) { 74 if(!c || m_cachedir.absolutePath().isEmpty()) {
74 qDebug() << "[HttpGet] disabling download cache"; 75 LOG_INFO() << "disabling download cache";
75 } 76 }
76 else { 77 else {
77 // append the cache path to make it unique in case the path points to 78 // append the cache path to make it unique in case the path points to
78 // the system temporary path. In that case using it directly might 79 // the system temporary path. In that case using it directly might
79 // cause problems. Extra path also used in configure dialog. 80 // cause problems. Extra path also used in configure dialog.
80 path += "/rbutil-cache"; 81 path += "/rbutil-cache";
81 qDebug() << "[HttpGet] setting cache folder to" << path; 82 LOG_INFO() << "setting cache folder to" << path;
82 m_cache = new QNetworkDiskCache(this); 83 m_cache = new QNetworkDiskCache(this);
83 m_cache->setCacheDirectory(path); 84 m_cache->setCacheDirectory(path);
84 } 85 }
@@ -97,7 +98,7 @@ QByteArray HttpGet::readAll()
97 98
98void HttpGet::setProxy(const QUrl &proxy) 99void HttpGet::setProxy(const QUrl &proxy)
99{ 100{
100 qDebug() << "[HttpGet] Proxy set to" << proxy; 101 LOG_INFO() << "Proxy set to" << proxy;
101 m_proxy.setType(QNetworkProxy::HttpProxy); 102 m_proxy.setType(QNetworkProxy::HttpProxy);
102 m_proxy.setHostName(proxy.host()); 103 m_proxy.setHostName(proxy.host());
103 m_proxy.setPort(proxy.port()); 104 m_proxy.setPort(proxy.port());
@@ -130,10 +131,10 @@ void HttpGet::requestFinished(QNetworkReply* reply)
130{ 131{
131 m_lastStatusCode 132 m_lastStatusCode
132 = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); 133 = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
133 qDebug() << "[HttpGet] Request finished, status code:" << m_lastStatusCode; 134 LOG_INFO() << "Request finished, status code:" << m_lastStatusCode;
134 m_lastServerTimestamp 135 m_lastServerTimestamp
135 = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().toLocalTime(); 136 = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().toLocalTime();
136 qDebug() << "[HttpGet] Data from cache:" 137 LOG_INFO() << "Data from cache:"
137 << reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool(); 138 << reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool();
138 m_lastRequestCached = 139 m_lastRequestCached =
139 reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool(); 140 reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool();
@@ -150,7 +151,7 @@ void HttpGet::requestFinished(QNetworkReply* reply)
150#else 151#else
151 url.setQuery(org.query()); 152 url.setQuery(org.query());
152#endif 153#endif
153 qDebug() << "[HttpGet] Redirected to" << url; 154 LOG_INFO() << "Redirected to" << url;
154 startRequest(url); 155 startRequest(url);
155 return; 156 return;
156 } 157 }
@@ -179,7 +180,7 @@ void HttpGet::downloadProgress(qint64 received, qint64 total)
179 180
180void HttpGet::startRequest(QUrl url) 181void HttpGet::startRequest(QUrl url)
181{ 182{
182 qDebug() << "[HttpGet] Request started"; 183 LOG_INFO() << "Request started";
183 QNetworkRequest req(url); 184 QNetworkRequest req(url);
184 if(!m_globalUserAgent.isEmpty()) 185 if(!m_globalUserAgent.isEmpty())
185 req.setRawHeader("User-Agent", m_globalUserAgent.toLatin1()); 186 req.setRawHeader("User-Agent", m_globalUserAgent.toLatin1());
@@ -194,15 +195,14 @@ void HttpGet::startRequest(QUrl url)
194 195
195void HttpGet::networkError(QNetworkReply::NetworkError error) 196void HttpGet::networkError(QNetworkReply::NetworkError error)
196{ 197{
197 qDebug() << "[HttpGet] NetworkError occured:" 198 LOG_ERROR() << "NetworkError occured:" << error << m_reply->errorString();
198 << error << m_reply->errorString();
199 m_lastErrorString = m_reply->errorString(); 199 m_lastErrorString = m_reply->errorString();
200} 200}
201 201
202 202
203bool HttpGet::getFile(const QUrl &url) 203bool HttpGet::getFile(const QUrl &url)
204{ 204{
205 qDebug() << "[HttpGet] Get URI" << url.toString(); 205 LOG_INFO() << "Get URI" << url.toString();
206 m_data.clear(); 206 m_data.clear();
207 startRequest(url); 207 startRequest(url);
208 208