QHttpRequestHeader header = QHttpRequestHeader ("POST","/index.cgi"); header.setContentType("application/x-www-form-urlencoded"); header.setValue("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6"); header.setValue("Host", "billing.oreol.net"); header.setValue("Referer", "https://billing.oreol.net/index.cgi"); header.setValue("Content-Type", "application/x-www-form-urlencoded"); header.setValue("language","english"); header.setValue("user", ui->cashLoginLine->text()); header.setValue("passwd", ui->cashPassLine->text()); header.setValue("logined", "Enter"); http.setHost("billing.oreol.net"); http.request(header);
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>302 Found</title></head><body><h1>Found</h1><p>The document has moved <a href="https://billing.oreol.net/index.cgi">here</a>.</p></body></html>
void Window::viewbalance(){ QString text = text.fromUtf8(http.readAll()); ui->cashStatus->setPlainText(text);}
C++ (Qt)voidRedirectHttp::onHeaderReceived( const QHttpResponseHeader& resp ){ switch( resp.statusCode() ) { case 301: //Moved Permanently case 302: case 307: //Temporary Redirect { QString redirectUrl = resp.value( "location" ); qDebug() << "Http request returned redirect (301, 302 or 307): " << redirectUrl; // blockSignals( true ); abort(); close(); QUrl url( redirectUrl ); // повторный запрос..
#include <QHttp>