[Qt-interest] [QT-interest] Cookie from webserver

luis navarro luis.navarro.dominguez at gmail.com
Mon Dec 14 07:06:20 CET 2009


Hi everybody. I really need help. I´m trying to get a cookie from a web
server. I´m using httpheader to make a POST operation (code below) to
/login.tgi. But previously i get a key from the web server when i try to
connect. That works fine and i always receive the key(For example:
aYZDFn3pFYwZom6). Next i should send the user, pass and key concatenated
into a string to log me into the web server. Here is not working because i
always receive:

HTTP/1.0 403 Forbidden

Connection: close

Content-Type: text/html

Set-Cookie: DLILPC=""; Version=1; Max-Age=0; Path=/

I really apreciate if anybody could give me some advice. Thanks.

void MainWindow::sendHttpHeader(QString operation, QString page, QString
host,QHttp *ihttp, QList<QString> &list){

QHttpRequestHeader req_head(operation,page);

req_head.setValue("Host",host);

req_head.setValue("User-Agent","QHTTP");

req_head.setValue("Accept",list.at(0));

req_head.setValue("Accept-Language","de,en;q=0.7,en-us;q=0.3");//es-es,es;q=0.8,en-us;q=0.5,en;q=0.3");

req_head.setValue("Accept-Encoding","gzip,deflate");

req_head.setValue("Accept-Charset","ISO-8859-1,UTF-8;q=0.7,*;q=0.7");

req_head.setValue("Keep-Alive","300");

req_head.setValue("Connection","keep-alive");

QList<QString> list1=list.mid(1,list.size()-1);

for (int i = 0; i <list1.size()/2; ++i)

req_head.setValue(list1.at(i*2),list1.at(i*2+1));

 ihttp->setHost(host,QHttp::ConnectionModeHttp,9998);


 QString str = "userpass";

str.append(this->httplastkey);

cripty->addData(str.toUtf8());

QString t1="Username=user&Password="+cripty->result().toHex();

ihttp->request(req_head,t1.toUtf8());
}
-- 
Atte.
Luis Navarro Domínguez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091214/d2874727/attachment.html 


More information about the Qt-interest-old mailing list