diff --git a/src/o2.cpp b/src/o2.cpp index a92c291..820fec8 100644 --- a/src/o2.cpp +++ b/src/o2.cpp @@ -265,6 +265,8 @@ bool O2::linked() { void O2::onVerificationReceived(const QMap response) { trace() << "O2::onVerificationReceived"; trace() << "" << response; + if (response.isEmpty()) //Chrome (Firefox, IE and Safari do not) sends one of these + return; //after normal one, which ends up as an error "Missing required parameter(s): code" - so just skip it emit closeBrowser(); if (response.contains("error")) { @@ -499,6 +501,16 @@ void O2::setReplyContent(const QByteArray& value) replyServer_->setReplyContent(value); } +QByteArray O2::replyContentType() +{ + return replyServer_->replyContentType(); +} + +void O2::setReplyContentType(const QByteArray& value) +{ + replyServer_->setReplyContentType(value); +} + bool O2::ignoreSslErrors() { return timedReplies_.ignoreSslErrors(); diff --git a/src/o2.h b/src/o2.h index 0769ef0..2076600 100644 --- a/src/o2.h +++ b/src/o2.h @@ -109,6 +109,10 @@ class O2: public QObject { QByteArray replyContent(); void setReplyContent(const QByteArray &value); + Q_PROPERTY(QByteArray replyContentType READ replyContentType WRITE setReplyContentType) + QByteArray replyContentType(); + void setReplyContentType(const QByteArray &value); + /// E.g. SurveyMonkey fails on Mac due to Ssl Error. Ignoring the error circumvents the problem Q_PROPERTY(bool ignoreSslErrors READ ignoreSslErrors WRITE setIgnoreSslErrors) bool ignoreSslErrors(); diff --git a/src/o2replyserver.cpp b/src/o2replyserver.cpp index 8b3479e..25f9ae0 100644 --- a/src/o2replyserver.cpp +++ b/src/o2replyserver.cpp @@ -19,6 +19,7 @@ O2ReplyServer::O2ReplyServer(QObject *parent): QTcpServer(parent) { connect(this, SIGNAL(newConnection()), this, SLOT(onIncomingConnection())); replyContent_ = ""; + replyContentType_ = "Content-Type: text/html; charset=\"utf-8\""; } O2ReplyServer::~O2ReplyServer() { @@ -37,7 +38,7 @@ void O2ReplyServer::onBytesReady() { } QByteArray reply; reply.append("HTTP/1.0 200 OK \r\n"); - reply.append("Content-Type: text/html; charset=\"utf-8\"\r\n"); + reply.append(replyContentType_ + "\r\n"); reply.append(QString("Content-Length: %1\r\n\r\n").arg(replyContent_.size())); reply.append(replyContent_); socket->write(reply); @@ -86,3 +87,13 @@ void O2ReplyServer::setReplyContent(const QByteArray& value) { replyContent_ = value; } + +QByteArray O2ReplyServer::replyContentType() +{ + return replyContentType_; +} + +void O2ReplyServer::setReplyContentType(const QByteArray& value) +{ + replyContentType_ = value; +} diff --git a/src/o2replyserver.h b/src/o2replyserver.h index f4bfcbb..ff3297f 100644 --- a/src/o2replyserver.h +++ b/src/o2replyserver.h @@ -19,6 +19,10 @@ class O2ReplyServer: public QTcpServer { QByteArray replyContent(); void setReplyContent(const QByteArray &value); + Q_PROPERTY(QByteArray replyContentType READ replyContentType WRITE setReplyContentType) + QByteArray replyContentType(); + void setReplyContentType(const QByteArray &value); + signals: void verificationReceived(QMap); @@ -28,7 +32,7 @@ public slots: QMap parseQueryParams(QByteArray *data); protected: - QByteArray replyContent_; + QByteArray replyContent_, replyContentType_; }; #endif // O2REPLYSERVER_H