summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2016-08-09 20:13:38 +0800
committerIru Cai <mytbk920423@gmail.com>2016-08-09 20:13:38 +0800
commitd421c2285d63d31a9c5a036b523eeaa3dcacc41b (patch)
tree519af3edfc8359f5b45b10ce8aad9ddb2e6fe892
parentc8a4ec5cb09c9e1ed10760f64e7336a45c3656c9 (diff)
downloadfqterm-d421c2285d63d31a9c5a036b523eeaa3dcacc41b.tar.xz
Fix relative redirection problem
-rw-r--r--src/utilities/fqterm_http.cpp17
1 files 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;
}