Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
- #include <QtNetwork/QNetworkAccessManager>
- #include <QtNetwork/QNetworkReply>
- #include <QtNetwork/QNetworkRequest>
- #include <QUrl>
- #include <QByteArray>
- #include <QString>
- #include <QTextCodec>
- MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
- {
- ui->setupUi(this);
- QNetworkAccessManager* manager= new QNetworkAccessManager(this);
- QByteArray Request;
- QUrl site("https://10.250.14.186:443/");
- QString Login= "******";
- QString Pass= "*****";
- QString Version= "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0";
- QByteArray postData;
- postData+= "a=auth" ;
- postData+= "&";
- postData+= "user=" + QUrl::toPercentEncoding(Login.toUtf8() );
- postData+= "&";
- postData+= "password=" + QUrl::toPercentEncoding(Pass.toUtf8() );
- QNetworkRequest request(site);
- request.setHeader(QNetworkRequest::UserAgentHeader, Version);
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
- QNetworkReply* reply= manager->post(request, postData);
- connect (reply, SIGNAL(sslErrors(QList<QSslError>)),reply,SLOT(ignoreSslErrors()));
- connect (reply, SIGNAL(finished()),this, SLOT(replyFinished()));
- //qDebug()<<QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() <<QSslSocket::sslLibraryVersionString();
- }
- void MainWindow::replyFinished()
- {
- QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
- connect (reply, SIGNAL(sslErrors(QList<QSslError>)),reply,SLOT(ignoreSslErrors()));
- // if (reply->error()== QNetworkReply::NoError)
- // {
- QByteArray content= reply->readAll();
- ui->textEdit->setPlainText(content.data());
- // }
- // else
- qDebug()<<reply->errorString() <<"ska";
- reply->deleteLater();
- }
- MainWindow::~MainWindow()
- {
- delete ui;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement