beim get request bekomm ich einen response aber beim post request bekomm ich nichts;//// an was liegt das?
Code: Alles auswählen
HttpTest::HttpTest(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags), set_cookie(false), request_counter(0)
{
ui.setupUi(this);
httpGetId = 0;
http = new QHttp(this);
connect(http, SIGNAL(requestFinished(int, bool)),
this, SLOT(httpRequestFinished(int, bool)));
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(http, SIGNAL(done(bool)),
this, SLOT(done(bool)));
}
void HttpTest::on_pushStart_clicked()
{
//Thread_Start = true;
http->setHost("games.orf.at", 80);
httpGetId = http->get("/millionenshow");
}
void HttpTest::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
QStringList list = responseHeader.keys();
if(!set_cookie) {
cookieid = responseHeader.value("set-cookie");
set_cookie = true;
}
qDebug() << responseheader.statusCode();
request_counter++;
}
void HttpTest::httpRequestFinished(int requestId, bool error)
{
if(error) {
QMessageBox::information(this, tr("HTTP"), tr("An Error occurred."));
}
else if (requestId == httpGetId) {
QByteArray data;
data = http->readAll();
QString str = data;
//ui.label->setText(str);
QMessageBox::information(this, "Request", data);
}
}
void HttpTest::done(bool error)
{
if(request_counter == 1) {
QHttp http_answere("games.orf.at");
QHttpRequestHeader header_answere("POST", "/millionenshow/main?action=check");
header_answere.setValue("Referer", "http://games.orf.at/millionenshow");
header_answere.setValue("Cookie", cookieid.mid(0, cookieid.length() - 22));
QString str1("qID=14&answer=2");
QByteArray postdata_answere(str1.toUtf8());
//QString postdata_answere("qID=14&answer=2");
httpGetId = http_answere.request(header_answere, postdata_answere);
}
/.....
}
qDebug() << responseheader.statusCode(); gibt -842150451 aus..hm