Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip invalid response from Chrome #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/o2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ bool O2::linked() {
void O2::onVerificationReceived(const QMap<QString, QString> 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")) {
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/o2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 12 additions & 1 deletion src/o2replyserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
O2ReplyServer::O2ReplyServer(QObject *parent): QTcpServer(parent) {
connect(this, SIGNAL(newConnection()), this, SLOT(onIncomingConnection()));
replyContent_ = "<HTML></HTML>";
replyContentType_ = "Content-Type: text/html; charset=\"utf-8\"";
}

O2ReplyServer::~O2ReplyServer() {
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
6 changes: 5 additions & 1 deletion src/o2replyserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString, QString>);

Expand All @@ -28,7 +32,7 @@ public slots:
QMap<QString, QString> parseQueryParams(QByteArray *data);

protected:
QByteArray replyContent_;
QByteArray replyContent_, replyContentType_;
};

#endif // O2REPLYSERVER_H