mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-11 22:22:33 -05:00
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));
|
http.setHost(url.host(), url.port(80));
|
||||||
// construct query (if any)
|
// construct query (if any)
|
||||||
QList<QPair<QString, QString> > qitems = url.queryItems();
|
QList<QPair<QString, QString> > qitems = url.queryItems();
|
||||||
QString query;
|
|
||||||
if(url.hasQuery()) {
|
if(url.hasQuery()) {
|
||||||
query = "?";
|
query = "?";
|
||||||
for(int i = 0; i < qitems.size(); i++)
|
for(int i = 0; i < qitems.size(); i++)
|
||||||
|
|
@ -177,13 +176,14 @@ void HttpGet::httpResponseHeader(const QHttpResponseHeader &resp)
|
||||||
http.abort();
|
http.abort();
|
||||||
}
|
}
|
||||||
// 301 -- moved permanently
|
// 301 -- moved permanently
|
||||||
|
// 302 -- found
|
||||||
// 303 -- see other
|
// 303 -- see other
|
||||||
// 307 -- moved temporarily
|
// 307 -- moved temporarily
|
||||||
// in all cases, header: location has the correct address so we can follow.
|
// 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
|
// start new request with new url
|
||||||
qDebug() << "http response" << response << "- following";
|
qDebug() << "http response" << response << "- following";
|
||||||
getFile(resp.value("location"));
|
getFile(resp.value("location") + query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class HttpGet : public QObject
|
||||||
int getRequest;
|
int getRequest;
|
||||||
QByteArray dataBuffer;
|
QByteArray dataBuffer;
|
||||||
bool outputToBuffer;
|
bool outputToBuffer;
|
||||||
|
QString query;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue