# HG changeset patch # User Chris Cannam # Date 1227823798 0 # Node ID 05383ee78f3e0591a91f5d0dc680a1975c121828 # Parent 438f4e295a9c3e4bc536aa706e6889180ba7d0ef * Support http redirects diff -r 438f4e295a9c -r 05383ee78f3e data/fileio/FileSource.cpp --- 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 #include -//#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());