Mercurial > hg > svcore
diff data/fileio/FileSource.cpp @ 496:05383ee78f3e
* Support http redirects
author | Chris Cannam |
---|---|
date | Thu, 27 Nov 2008 22:09:58 +0000 |
parents | dddd4ab77068 |
children | b6dc6c7f402c |
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp Wed Nov 26 13:55:00 2008 +0000 +++ b/data/fileio/FileSource.cpp Thu Nov 27 22:09:58 2008 +0000 @@ -29,7 +29,7 @@ #include <iostream> #include <cstdlib> -//#define DEBUG_FILE_SOURCE 1 +#define DEBUG_FILE_SOURCE 1 int FileSource::m_count = 0; @@ -546,6 +546,28 @@ FileSource::httpResponseHeaderReceived(const QHttpResponseHeader &resp) { m_lastStatus = resp.statusCode(); + if (m_lastStatus / 100 == 3) { + QString location = resp.value("Location"); +#ifdef DEBUG_FILE_SOURCE + std::cerr << "FileSource::responseHeaderReceived: redirect to \"" + << location.toStdString() << "\" received" << std::endl; +#endif + if (location != "") { + QUrl newUrl(location); + if (newUrl != m_url) { + m_url = newUrl; + m_lastStatus = 0; + disconnect(m_http, SIGNAL(done(bool)), this, SLOT(done(bool))); + disconnect(m_http, SIGNAL(dataReadProgress(int, int)), + this, SLOT(dataReadProgress(int, int))); + m_http->abort(); + m_http->deleteLater(); + m_http = 0; + init(); + return; + } + } + } if (m_lastStatus / 100 >= 4) { m_errorString = QString("%1 %2") .arg(resp.statusCode()).arg(resp.reasonPhrase());