summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-02-09 10:29:24 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-02-09 12:08:39 (GMT)
commit74d3ef60ac8dfa12c90442062307e0c4b2600d03 (patch)
tree1b847d6ef1006f928020a46ecfae1e3f18cd7194
parent4519080aacc480acea59758e4ca4efeed599aaec (diff)
downloadQt-74d3ef60ac8dfa12c90442062307e0c4b2600d03.zip
Qt-74d3ef60ac8dfa12c90442062307e0c4b2600d03.tar.gz
Qt-74d3ef60ac8dfa12c90442062307e0c4b2600d03.tar.bz2
Demo browser: Better handleUnsupportedContent implementation
Do warnings instead of downloads for sub resources. Show error message for main resources. Reviewed-by: Tor Arne
-rw-r--r--demos/browser/webview.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/demos/browser/webview.cpp b/demos/browser/webview.cpp
index 1a7e38a..2f9b3e6 100644
--- a/demos/browser/webview.cpp
+++ b/demos/browser/webview.cpp
@@ -143,11 +143,19 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
- if (reply->error() == QNetworkReply::NoError) {
- BrowserApplication::downloadManager()->handleUnsupportedContent(reply);
+ QString errorString = reply->errorString();
+
+ if (m_loadingUrl != reply->url()) {
+ // sub resource of this page
+ qWarning() << "Resource" << reply->url().toEncoded() << "has unknown Content-Type, will be ignored.";
+ reply->deleteLater();
return;
}
+ if (reply->error() == QNetworkReply::NoError && !reply->header(QNetworkRequest::ContentTypeHeader).isValid()) {
+ errorString = "Unknown Content-Type";
+ }
+
QFile file(QLatin1String(":/notfound.html"));
bool isOpened = file.open(QIODevice::ReadOnly);
Q_ASSERT(isOpened);
@@ -156,7 +164,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
QString title = tr("Error loading page: %1").arg(reply->url().toString());
QString html = QString(QLatin1String(file.readAll()))
.arg(title)
- .arg(reply->errorString())
+ .arg(errorString)
.arg(reply->url().toString());
QBuffer imageBuffer;