From d421c2285d63d31a9c5a036b523eeaa3dcacc41b Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Tue, 9 Aug 2016 20:13:38 +0800 Subject: Fix relative redirection problem --- src/utilities/fqterm_http.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/utilities/fqterm_http.cpp b/src/utilities/fqterm_http.cpp index 57cde46..7ea61cc 100644 --- a/src/utilities/fqterm_http.cpp +++ b/src/utilities/fqterm_http.cpp @@ -95,16 +95,15 @@ void FQTermHttp::getLink(const QUrl& url, bool preview) { FQ_VERIFY(connect(netreply_.data(), SIGNAL(metaDataChanged()), this, SLOT(httpResponse()))); } -void FQTermHttp::httpResponse() { +void FQTermHttp::httpResponse() { if (netreply_->hasRawHeader("Location")) { - //FIXME: according to RC, this code still could not work - //if the server send the relative location. - QString realLocation = netreply_->header(QNetworkRequest::LocationHeader).toString(); - QUrl u = realLocation; - if (u.isRelative() ) { - u=netreply_->url().resolved(u); - } - cacheFileName_ = QFileInfo(u.path()).fileName(); // update filename + // use rawHeader("Location") instead of header(QNetworkRequest::LocationHeader) + // it works for both absolute and relative redirection + QUrl u(netreply_->rawHeader("Location")); + if (u.isRelative() ) { + u=netreply_->url().resolved(u); + } + cacheFileName_ = QFileInfo(u.path()).fileName(); // update filename getLink(u,isPreview_); return; } -- cgit v1.2.3