Fix auth example.

This commit is contained in:
Nathan Osman
2017-08-05 11:35:57 -07:00
parent c0c7d88366
commit ad01f31cf2
2 changed files with 14 additions and 4 deletions

View File

@@ -21,6 +21,8 @@
*/
#include <QCoreApplication>
#include <QDir>
#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkAccessManager>
@@ -28,15 +30,13 @@
#include <QNetworkReply>
#include <QUrl>
#include <qhttpengine/localfile.h>
int main(int argc, char * argv[])
{
QCoreApplication a(argc, argv);
// Attempt to open the local file and read from it
QHttpEngine::LocalFile file;
if (!file.open()) {
QFile file(QDir::home().absoluteFilePath(".authserver"));
if (!file.open(QIODevice::ReadOnly)) {
qCritical("Unable to open local file - is server running?");
return 1;
}
@@ -48,6 +48,9 @@ int main(int argc, char * argv[])
return 1;
}
// Close the file
file.close();
// Create a request to the server, using the provided port and passing the
// auth token as a custom HTTP header
QUrl url(QString("http://127.0.0.1:%1/").arg(obj.value("port").toInt()));