diff options
Diffstat (limited to 'rbutil/rbutilqt/httpget.cpp')
-rw-r--r-- | rbutil/rbutilqt/httpget.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/rbutil/rbutilqt/httpget.cpp b/rbutil/rbutilqt/httpget.cpp index 768463d1f2..1ceaeb002c 100644 --- a/rbutil/rbutilqt/httpget.cpp +++ b/rbutil/rbutilqt/httpget.cpp | |||
@@ -23,14 +23,13 @@ | |||
23 | 23 | ||
24 | #include "httpget.h" | 24 | #include "httpget.h" |
25 | 25 | ||
26 | QDir HttpGet::m_globalCache; | 26 | QDir HttpGet::m_globalCache; //< global cach path value for new objects |
27 | QUrl HttpGet::m_globalProxy; | 27 | QUrl HttpGet::m_globalProxy; //< global proxy value for new objects |
28 | 28 | ||
29 | HttpGet::HttpGet(QObject *parent) | 29 | HttpGet::HttpGet(QObject *parent) |
30 | : QObject(parent) | 30 | : QObject(parent) |
31 | { | 31 | { |
32 | m_usecache = false; | 32 | m_usecache = false; |
33 | qDebug() << "--> HttpGet::HttpGet()"; | ||
34 | outputToBuffer = true; | 33 | outputToBuffer = true; |
35 | cached = false; | 34 | cached = false; |
36 | getRequest = -1; | 35 | getRequest = -1; |
@@ -41,7 +40,6 @@ HttpGet::HttpGet(QObject *parent) | |||
41 | // default to global proxy / cache if not empty. | 40 | // default to global proxy / cache if not empty. |
42 | // proxy is automatically enabled, disable it by setting an empty proxy | 41 | // proxy is automatically enabled, disable it by setting an empty proxy |
43 | // cache is enabled to be in line, can get disabled with setCache(bool) | 42 | // cache is enabled to be in line, can get disabled with setCache(bool) |
44 | qDebug() << "setting global proxy / cache"; | ||
45 | if(!m_globalProxy.isEmpty()) | 43 | if(!m_globalProxy.isEmpty()) |
46 | setProxy(m_globalProxy); | 44 | setProxy(m_globalProxy); |
47 | m_usecache = false; | 45 | m_usecache = false; |
@@ -58,6 +56,8 @@ HttpGet::HttpGet(QObject *parent) | |||
58 | } | 56 | } |
59 | 57 | ||
60 | 58 | ||
59 | //! @brief set cache path | ||
60 | // @param d new directory to use as cache path | ||
61 | void HttpGet::setCache(QDir d) | 61 | void HttpGet::setCache(QDir d) |
62 | { | 62 | { |
63 | m_cachedir = d; | 63 | m_cachedir = d; |
@@ -68,6 +68,9 @@ void HttpGet::setCache(QDir d) | |||
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | /** @brief enable / disable cache useage | ||
72 | * @param c set cache usage | ||
73 | */ | ||
71 | void HttpGet::setCache(bool c) | 74 | void HttpGet::setCache(bool c) |
72 | { | 75 | { |
73 | qDebug() << "setCache(bool)" << c; | 76 | qDebug() << "setCache(bool)" << c; |
@@ -103,6 +106,9 @@ QByteArray HttpGet::readAll() | |||
103 | } | 106 | } |
104 | 107 | ||
105 | 108 | ||
109 | /** @brief get http error | ||
110 | * @return http error | ||
111 | */ | ||
106 | QHttp::Error HttpGet::error() | 112 | QHttp::Error HttpGet::error() |
107 | { | 113 | { |
108 | return http.error(); | 114 | return http.error(); |
@@ -219,13 +225,15 @@ bool HttpGet::getFile(const QUrl &url) | |||
219 | qDebug() << query; | 225 | qDebug() << query; |
220 | } | 226 | } |
221 | 227 | ||
228 | QString path; | ||
229 | path = QString(QUrl::toPercentEncoding(url.path(), "/")); | ||
222 | if(outputToBuffer) { | 230 | if(outputToBuffer) { |
223 | qDebug() << "[HTTP] downloading to buffer:" << url.toString(); | 231 | qDebug() << "[HTTP] downloading to buffer:" << url.toString(); |
224 | getRequest = http.get(url.path() + query); | 232 | getRequest = http.get(path + query); |
225 | } | 233 | } |
226 | else { | 234 | else { |
227 | qDebug() << "[HTTP] downloading to file:" << url.toString() << qPrintable(outputFile->fileName()); | 235 | qDebug() << "[HTTP] downloading to file:" << url.toString() << qPrintable(outputFile->fileName()); |
228 | getRequest = http.get(url.path() + query, outputFile); | 236 | getRequest = http.get(path + query, outputFile); |
229 | } | 237 | } |
230 | qDebug() << "[HTTP] request scheduled: GET" << getRequest; | 238 | qDebug() << "[HTTP] request scheduled: GET" << getRequest; |
231 | 239 | ||