i change QHttp to QNetworkAccessManager and set base64 but still dont work ;(
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
networkManager = new QNetworkAccessManager(this);
connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(send()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::send()
{
postData.append("name=Gaths&");
postData.append("password=qwerasdf&");
postData.append("s1=Login&");
postData.append("w=1024%3A600&");
postData.append("login=1359443665");
networkManager
->post
(QNetworkRequest
(QUrl("http://ts9.travian.pl/dorf1.php")), postData.
toBase64());
}
void MainWindow::requestFinished(QNetworkReply *reply)
{
if(reply->isOpen())
{
ui->plainTextEdit->setPlainText(reply->readAll());
reply->close();
}
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
networkManager = new QNetworkAccessManager(this);
connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(send()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::send()
{
QByteArray postData;
postData.append("name=Gaths&");
postData.append("password=qwerasdf&");
postData.append("s1=Login&");
postData.append("w=1024%3A600&");
postData.append("login=1359443665");
networkManager->post(QNetworkRequest(QUrl("http://ts9.travian.pl/dorf1.php")), postData.toBase64());
}
void MainWindow::requestFinished(QNetworkReply *reply)
{
if(reply->isOpen())
{
ui->plainTextEdit->setPlainText(reply->readAll());
reply->close();
}
}
To copy to clipboard, switch view to plain text mode
If i set postData.toBase64() or just postData, result its the same , in wireshark write "Media Type: application/octet-stream 67 bytes", but should by "Line-based text data: application/x-www-form-urlencoded" .
How i can convert postData to x-www-form-urlencoded.
WORKKKKK!!!!!
void MainWindow::send()
{
postData.addQueryItem("name", "Gaths");
postData.addQueryItem("password","qwerasdf");
postData.addQueryItem("s1","Login");
postData.addQueryItem("w","1024%3A600");
postData.addQueryItem("login","1359443665");
QNetworkRequest request
(QUrl("http://ts9.travian.pl/dorf1.php"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
networkManager->post(request, postData.encodedQuery());
}
void MainWindow::send()
{
QUrl postData;
postData.addQueryItem("name", "Gaths");
postData.addQueryItem("password","qwerasdf");
postData.addQueryItem("s1","Login");
postData.addQueryItem("w","1024%3A600");
postData.addQueryItem("login","1359443665");
QNetworkRequest request(QUrl("http://ts9.travian.pl/dorf1.php"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
networkManager->post(request, postData.encodedQuery());
}
To copy to clipboard, switch view to plain text mode
THX for help
Bookmarks