forked from len0rd/rockbox
302 is also a valid redirect. Also keep the original query when redirecting.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14362 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
57dd552e00
commit
53fbd6d01d
2 changed files with 4 additions and 3 deletions
|
@ -111,7 +111,6 @@ bool HttpGet::getFile(const QUrl &url)
|
|||
http.setHost(url.host(), url.port(80));
|
||||
// construct query (if any)
|
||||
QList<QPair<QString, QString> > qitems = url.queryItems();
|
||||
QString query;
|
||||
if(url.hasQuery()) {
|
||||
query = "?";
|
||||
for(int i = 0; i < qitems.size(); i++)
|
||||
|
@ -177,13 +176,14 @@ void HttpGet::httpResponseHeader(const QHttpResponseHeader &resp)
|
|||
http.abort();
|
||||
}
|
||||
// 301 -- moved permanently
|
||||
// 302 -- found
|
||||
// 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) {
|
||||
if(response == 301 || response == 302 || response == 303 || response == 307) {
|
||||
// start new request with new url
|
||||
qDebug() << "http response" << response << "- following";
|
||||
getFile(resp.value("location"));
|
||||
getFile(resp.value("location") + query);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ class HttpGet : public QObject
|
|||
int getRequest;
|
||||
QByteArray dataBuffer;
|
||||
bool outputToBuffer;
|
||||
QString query;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue