summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/httpget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/httpget.cpp')
-rw-r--r--rbutil/rbutilqt/httpget.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/rbutil/rbutilqt/httpget.cpp b/rbutil/rbutilqt/httpget.cpp
index acd8940b77..a45769c246 100644
--- a/rbutil/rbutilqt/httpget.cpp
+++ b/rbutil/rbutilqt/httpget.cpp
@@ -23,6 +23,8 @@
23 23
24#include "httpget.h" 24#include "httpget.h"
25 25
26QDir HttpGet::m_globalCache;
27QUrl HttpGet::m_globalProxy;
26 28
27HttpGet::HttpGet(QObject *parent) 29HttpGet::HttpGet(QObject *parent)
28 : QObject(parent) 30 : QObject(parent)
@@ -36,6 +38,14 @@ HttpGet::HttpGet(QObject *parent)
36 // hint about this in the http response instead of nonsense. 38 // hint about this in the http response instead of nonsense.
37 response = -1; 39 response = -1;
38 40
41 // default to global proxy / cache if not empty.
42 // 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)
44 qDebug() << "setting global proxy / cache";
45 if(!m_globalProxy.isEmpty())
46 setProxy(m_globalProxy);
47 m_usecache = false;
48 m_cachedir = m_globalCache;
39 connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool))); 49 connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
40 connect(&http, SIGNAL(dataReadProgress(int, int)), this, SLOT(httpProgress(int, int))); 50 connect(&http, SIGNAL(dataReadProgress(int, int)), this, SLOT(httpProgress(int, int)));
41 connect(&http, SIGNAL(requestFinished(int, bool)), this, SLOT(httpFinished(int, bool))); 51 connect(&http, SIGNAL(requestFinished(int, bool)), this, SLOT(httpFinished(int, bool)));
@@ -60,13 +70,14 @@ void HttpGet::setCache(QDir d)
60 result = m_cachedir.mkdir("rbutil-cache"); 70 result = m_cachedir.mkdir("rbutil-cache");
61 } 71 }
62 else result = false; 72 else result = false;
63 qDebug() << "HttpGet::setCache(QDir)" << result; 73 qDebug() << "HttpGet::setCache(QDir)" << d << result;
64 m_usecache = result; 74 m_usecache = result;
65} 75}
66 76
67 77
68void HttpGet::setCache(bool c) 78void HttpGet::setCache(bool c)
69{ 79{
80 qDebug() << "setCache(bool)" << c;
70 m_usecache = c; 81 m_usecache = c;
71} 82}
72 83
@@ -91,8 +102,19 @@ void HttpGet::httpProgress(int read, int total)
91 102
92void HttpGet::setProxy(const QUrl &proxy) 103void HttpGet::setProxy(const QUrl &proxy)
93{ 104{
94 qDebug() << "HttpGet::setProxy" << proxy.toString(); 105 qDebug() << "HttpGet::setProxy(QUrl)" << proxy.toString();
95 http.setProxy(proxy.host(), proxy.port(), proxy.userName(), proxy.password()); 106 m_proxy = proxy;
107 http.setProxy(m_proxy.host(), m_proxy.port(), m_proxy.userName(), m_proxy.password());
108}
109
110
111void HttpGet::setProxy(bool enable)
112{
113 qDebug() << "HttpGet::setProxy(bool)" << enable;
114 if(enable)
115 http.setProxy(m_proxy.host(), m_proxy.port(), m_proxy.userName(), m_proxy.password());
116 else
117 http.setProxy("", 0);
96} 118}
97 119
98 120
@@ -171,6 +193,7 @@ bool HttpGet::getFile(const QUrl &url)
171 else { 193 else {
172 qDebug() << "[HTTP] cache DISABLED"; 194 qDebug() << "[HTTP] cache DISABLED";
173 } 195 }
196
174 http.setHost(url.host(), url.port(80)); 197 http.setHost(url.host(), url.port(80));
175 // construct query (if any) 198 // construct query (if any)
176 QList<QPair<QString, QString> > qitems = url.queryItems(); 199 QList<QPair<QString, QString> > qitems = url.queryItems();