I want to be able to read the headers sent back from a webpage in SSL mode. My Qt app however can't reach the webpage because it's in SSL mode I am gathering? Normal webview browsing in SSL is possible in my app using this connect:
connect(view->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )),
this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError> & )));
This suppresses the SSL errors in the webview but I have a separate function which get's the headers using this method:
//Send a request to validate URL
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(QUrl(text));
request.setRawHeader("User-Agent", "MyApp1.0");
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
QNetworkReply *reply = manager->get(request);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
qDebug() << "QLoop: " << reply->rawHeader("My-Application");
if(reply->rawHeader("My-Application") == "1"){
appUrl = text;
}
I need this method because I set a config file with our webapps URL in it before the the app will connect to it using webview->load(QURL(appUrl ))
. Just not sure how to supress/handle SSL errors using QNetworkAccessManager?
You need to connect your QNAM objects signal sslErrors(QNetworkReply *, QList<QSslError>)
to a slot where you set QNetworkReply::ignoreSslErrors()
and that'll allow QNAM to continue running. Qt Docs on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With