You must only read the incomming header and resend Session as cookie..
http://www.qt-apps.org/content/show....?content=76432
read ...
//////////////std::cout << "Last http header respond is " << headercode << std::endl;
////////std::cout << "contentLength " << responseHeader.contentLength() << std::endl;
/////////std::cout << "contentType " << qPrintable(responseHeader.contentType()) << std::endl;
for (int i = 0; i < headerin.size(); ++i) {
/////////////std::cout << "" << qPrintable(headerin.at(i)) << " ->" << qPrintable(responseHeader.value(headerin.at(i))) << std::endl;
const QString HeaderValue
= responseHeader.
value(headerin.
at(i
));
if (headerin.at(i) == "content-encoding") {
if (HeaderValue.contains("gzip",Qt::CaseInsensitive)) {
Compressed = true;
zipmode = GZIP_MODE;
} else if (HeaderValue.contains("deflate",Qt::CaseInsensitive)) {
Compressed = true;
zipmode = DEFLATE_MODE;
} else if (HeaderValue.contains("qcompress",Qt::CaseInsensitive)) {
Compressed = true;
zipmode = QT_MODE;
}
}
if (headerin.at(i) == "set-cookie") {
if (!CookieList.contains(HeaderValue,Qt::CaseInsensitive)) {
CookieList.append( HeaderValue );
}
}
{
headercode = lastResponse().statusCode();
headerresponder =""; //// headerin.join("\n");
qDebug() << "### headerin " << headerin;
HeaderIncome.clear();
for (int i = 0; i < headerin.size(); ++i) {
const QString HeaderValue
= responseHeader.
value(headerin.
at(i
));
//////qDebug() << "### HeaderValue " << HeaderValue;
HeaderIncome.insert(headerin.at(i),HeaderValue);
headerresponder.
append(QString("%1=%2\n").
arg(headerin.
at(i
)).
arg(HeaderValue
));
}
}
//////////////std::cout << "Last http header respond is " << headercode << std::endl;
////////std::cout << "contentLength " << responseHeader.contentLength() << std::endl;
/////////std::cout << "contentType " << qPrintable(responseHeader.contentType()) << std::endl;
QStringList headerin = responseHeader.keys();
for (int i = 0; i < headerin.size(); ++i) {
/////////////std::cout << "" << qPrintable(headerin.at(i)) << " ->" << qPrintable(responseHeader.value(headerin.at(i))) << std::endl;
const QString HeaderValue = responseHeader.value(headerin.at(i));
if (headerin.at(i) == "content-encoding") {
if (HeaderValue.contains("gzip",Qt::CaseInsensitive)) {
Compressed = true;
zipmode = GZIP_MODE;
} else if (HeaderValue.contains("deflate",Qt::CaseInsensitive)) {
Compressed = true;
zipmode = DEFLATE_MODE;
} else if (HeaderValue.contains("qcompress",Qt::CaseInsensitive)) {
Compressed = true;
zipmode = QT_MODE;
}
}
if (headerin.at(i) == "set-cookie") {
if (!CookieList.contains(HeaderValue,Qt::CaseInsensitive)) {
CookieList.append( HeaderValue );
}
}
void Communicator::SaveData(const QHttpResponseHeader &responseHeader )
{
headercode = lastResponse().statusCode();
QStringList headerin = responseHeader.keys();
headerresponder =""; //// headerin.join("\n");
qDebug() << "### headerin " << headerin;
HeaderIncome.clear();
for (int i = 0; i < headerin.size(); ++i) {
const QString HeaderValue = responseHeader.value(headerin.at(i));
//////qDebug() << "### HeaderValue " << HeaderValue;
HeaderIncome.insert(headerin.at(i),HeaderValue);
headerresponder.append(QString("%1=%2\n").arg(headerin.at(i)).arg(HeaderValue));
}
}
To copy to clipboard, switch view to plain text mode
resend CookieList
{
/* QHttpRequestHeader header;
*/
///////////std::cout << "### Send cookie ->" << qPrintable(val) << std::endl;
header.setValue(nam,val);
}
void AppendHeader( const QString nam , const QString val )
{
/* QHttpRequestHeader header;
*/
///////////std::cout << "### Send cookie ->" << qPrintable(val) << std::endl;
header.setValue(nam,val);
}
To copy to clipboard, switch view to plain text mode
http://fop-miniscribus.googlecode.co...mmunicator.cpp
IMO: is not code from shool ... but its run..
Bookmarks