Skip to content
Newer
Older
100644 28 lines (23 sloc) 953 Bytes
353fe86 @halogenandtoast Handle unsupported content types gracefully
halogenandtoast authored Sep 15, 2011
1 #include "UnsupportedContentHandler.h"
2 #include "WebPage.h"
3 #include <QNetworkReply>
4
5 UnsupportedContentHandler::UnsupportedContentHandler(WebPage *page, QNetworkReply *reply, QObject *parent) : QObject(parent) {
6 m_page = page;
7 m_reply = reply;
8 connect(m_reply, SIGNAL(finished()), this, SLOT(handleUnsupportedContent()));
9 disconnect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
10 }
11
12 void UnsupportedContentHandler::handleUnsupportedContent() {
d8020ce @jferris Treat fewer responses as fatal failures
jferris authored Jul 10, 2012
13 this->renderNonHtmlContent();
14 this->finish();
9257fe3 @halogenandtoast Cleanup
halogenandtoast authored Sep 23, 2011
15 this->deleteLater();
16 }
17
d8020ce @jferris Treat fewer responses as fatal failures
jferris authored Jul 11, 2012
18 void UnsupportedContentHandler::renderNonHtmlContent() {
353fe86 @halogenandtoast Handle unsupported content types gracefully
halogenandtoast authored Sep 15, 2011
19 QByteArray text = m_reply->readAll();
20 m_page->mainFrame()->setContent(text, QString("text/plain"), m_reply->url());
9257fe3 @halogenandtoast Cleanup
halogenandtoast authored Sep 23, 2011
21 }
22
d8020ce @jferris Treat fewer responses as fatal failures
jferris authored Jul 11, 2012
23 void UnsupportedContentHandler::finish() {
353fe86 @halogenandtoast Handle unsupported content types gracefully
halogenandtoast authored Sep 15, 2011
24 connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
784b9b7 @halogenandtoast Setup multi-window sync.
halogenandtoast authored Jun 29, 2012
25 m_page->networkAccessManagerFinishedReply(m_reply);
d8020ce @jferris Treat fewer responses as fatal failures
jferris authored Jul 11, 2012
26 m_page->loadFinished(true);
353fe86 @halogenandtoast Handle unsupported content types gracefully
halogenandtoast authored Sep 15, 2011
27 }
Something went wrong with that request. Please try again.