summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-15 20:08:02 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-15 20:08:02 +0000
commit57dd552e003481a3d08afd7a8ea1be11f4390ce2 (patch)
tree25209518f1278f22a9be9d40c833ba38ff1abcff
parentba8ec4a605c1415bc1ad63cb95c598bfde5e3e9a (diff)
downloadrockbox-57dd552e003481a3d08afd7a8ea1be11f4390ce2.zip
rockbox-57dd552e003481a3d08afd7a8ea1be11f4390ce2.tar.gz
rockbox-57dd552e003481a3d08afd7a8ea1be11f4390ce2.tar.bz2
rockbox-57dd552e003481a3d08afd7a8ea1be11f4390ce2.tar.xz
Don't close http connection manually, the destructor will do that anyway. Fixes some download problems. Also add support for following moved documents (http status 301, 303 and 307).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14361 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/httpget.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/rbutil/rbutilqt/httpget.cpp b/rbutil/rbutilqt/httpget.cpp
index d1c80b8..1f9205e 100644
--- a/rbutil/rbutilqt/httpget.cpp
+++ b/rbutil/rbutilqt/httpget.cpp
@@ -129,7 +129,6 @@ bool HttpGet::getFile(const QUrl &url)
}
qDebug() << "request scheduled: GET" << getRequest;
- http.close();
return true;
}
@@ -137,7 +136,7 @@ bool HttpGet::getFile(const QUrl &url)
void HttpGet::httpDone(bool error)
{
if (error) {
- qDebug() << "Error: " << qPrintable(http.errorString()) << endl;
+ qDebug() << "Error: " << qPrintable(http.errorString()) << httpResponse();
}
if(!outputToBuffer)
outputFile->close();
@@ -173,7 +172,19 @@ void HttpGet::httpResponseHeader(const QHttpResponseHeader &resp)
// if there is a network error abort all scheduled requests for
// this download
response = resp.statusCode();
- if(response != 200) http.abort();
+ if(response != 200) {
+ qDebug() << "http response error:" << response << resp.reasonPhrase();
+ http.abort();
+ }
+ // 301 -- moved permanently
+ // 303 -- see other
+ // 307 -- moved temporarily
+ // in all cases, header: location has the correct address so we can follow.
+ if(response == 301 || response == 303 || response == 307) {
+ // start new request with new url
+ qDebug() << "http response" << response << "- following";
+ getFile(resp.value("location"));
+ }
}