Make ignoring SSL errors an option.

webkit_server takes an --ignore-ssl-errors argument.
This commit is contained in:
Andrew Wason 2011-09-28 12:09:11 -04:00 committed by Matthew Mongeau
parent 9cfc6b10f1
commit f57b3a3d15
5 changed files with 23 additions and 4 deletions

View File

@ -4,9 +4,10 @@
#include <QTcpServer>
Server::Server(QObject *parent) : QObject(parent) {
Server::Server(QObject *parent, bool ignoreSslErrors) : QObject(parent) {
m_tcp_server = new QTcpServer(this);
m_page = new WebPage(this);
m_page->setIgnoreSslErrors(ignoreSslErrors);
}
bool Server::start() {

View File

@ -7,7 +7,7 @@ class Server : public QObject {
Q_OBJECT
public:
Server(QObject *parent = 0);
Server(QObject *parent, bool ignoreSslErrors);
bool start();
quint16 server_port() const;

View File

@ -194,9 +194,19 @@ void WebPage::replyFinished(QNetworkReply *reply) {
}
void WebPage::ignoreSslErrors(QNetworkReply *reply, const QList<QSslError> &errors) {
reply->ignoreSslErrors(errors);
if (m_ignoreSslErrors)
reply->ignoreSslErrors(errors);
}
void WebPage::setIgnoreSslErrors(bool ignore) {
m_ignoreSslErrors = ignore;
}
bool WebPage::ignoreSslErrors() {
return m_ignoreSslErrors;
}
int WebPage::getLastStatus() {
return m_lastStatus;
}

View File

@ -15,6 +15,8 @@ class WebPage : public QWebPage {
void setCustomNetworkAccessManager();
bool render(const QString &fileName);
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
void setIgnoreSslErrors(bool ignore);
bool ignoreSslErrors();
public slots:
bool shouldInterruptJavaScript();
@ -47,5 +49,6 @@ class WebPage : public QWebPage {
void setUserStylesheet();
int m_lastStatus;
QString m_pageHeaders;
bool m_ignoreSslErrors;
};

View File

@ -18,10 +18,15 @@ int main(int argc, char **argv) {
app.setOrganizationName("thoughtbot, inc");
app.setOrganizationDomain("thoughtbot.com");
Server server;
QStringList args = app.arguments();
bool ignoreSslErrors = args.contains("--ignore-ssl-errors");
Server server(0, ignoreSslErrors);
if (server.start()) {
std::cout << "Capybara-webkit server started, listening on port: " << server.server_port() << std::endl;
if (ignoreSslErrors)
std::cout << "Ignoring SSL errors" << std::endl;
return app.exec();
} else {
std::cerr << "Couldn't start capybara-webkit server" << std::endl;