summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2008-04-13 18:43:51 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2008-04-13 18:43:51 +0000
commit73d1eb4ac06809b64a0545bae22f7e436d3c8b70 (patch)
treea4660c80a97ad785d314da737f5974103dee2daa
parentbe77cf5279da938de8b120665fe00c9124490df5 (diff)
downloadrockbox-73d1eb4ac06809b64a0545bae22f7e436d3c8b70.tar.gz
rockbox-73d1eb4ac06809b64a0545bae22f7e436d3c8b70.zip
Make httpget class work with URI paths containing characters that need to be percent-encoded. Fixes FS#8872. Add a few comments.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17099 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/httpget.cpp20
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
26QDir HttpGet::m_globalCache; 26QDir HttpGet::m_globalCache; //< global cach path value for new objects
27QUrl HttpGet::m_globalProxy; 27QUrl HttpGet::m_globalProxy; //< global proxy value for new objects
28 28
29HttpGet::HttpGet(QObject *parent) 29HttpGet::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
61void HttpGet::setCache(QDir d) 61void 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 */
71void HttpGet::setCache(bool c) 74void 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 */
106QHttp::Error HttpGet::error() 112QHttp::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