typedef QMap<int, QStringList> cookiepam;
cookiepam ActualCook;
/* each request i resend the cookie from last session phpsession id... or other */
resendcoo.clear();
cookiepam ::Iterator it;
for ( it = ActualCook.begin(); it != ActualCook.end(); ++it ) {
resendcoo.append(oneci);
}
header.setValue("Cookie",resendcoo.join(";"));
/* take cookie from header */
{
ActualCook.clear();
QStringList cookielist
= responseHeader.
allValues("set-cookie");
for (int i = 0; i < cookielist.size(); ++i) {
QString cokeline
= cookielist.
at(i
);
QString cookiename
= onlines.
at(0);
QString cookievalue
= onlines.
at(1);
ActualCook.
insert(i,
QStringList() << cookiename << Url_Decode
(cookievalue
) << actualurl
);
/////////////////qDebug() << "### entry set-cookie pos=" << i << " name= " << cookiename << " value=" << Url_Decode(cookievalue);
}
//////////emit WatReturn(QString("One code=%1 - Other say = %2 \n%3").arg( responseHeader.statusCode() ).arg( responseHeader.reasonPhrase() ).arg(CookieVars()) );
}
/* decode cookie value */
{
/*
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
Dollar ("$") 24
Ampersand ("&") 26
Plus ("+") 2B
Comma (",") 2C
Forward slash/Virgule ("/") 2F
Colon (":") 3A
Semi-colon (";") 3B
Equals ("=") 3D
Question mark ("?") 3F
'At' symbol ("@") 40
Left Curly Brace ("{") 7B
Right Curly Brace ("}") 7D
Vertical Bar/Pipe ("|") 7C
Backslash ("\") 5C
Caret ("^") 5E
Tilde ("~") 7E
Left Square Bracket ("[") 5B
Right Square Bracket ("]") 5D
Grave Accent ("`") 60
*/
QString notaccept
= "%60|%5D|%5B|%7E|%5E|%5C|%7C|%7D|%7B";
notallow = notaccept.split("|");
for (int i = 0; i < notallow.size(); ++i) {
if ( indata.contains(notallow.at(i)) ) {
return blnull;
}
}
QString spaceout
= indata.
replace("%20",
" ");
spaceout = spaceout.replace("%3A",":");
spaceout = spaceout.replace("%3B",";");
spaceout = spaceout.replace("%3D","=");
spaceout = spaceout.replace("%2F","/");
spaceout = spaceout.replace("%3F","?");
spaceout = spaceout.replace("%40","@");
spaceout = spaceout.replace("%24","$");
spaceout = spaceout.replace("%2B","+");
spaceout = spaceout.replace("+"," ");
int zool = spaceout.indexOf(";",0);
return spaceout.left(zool);;
}
typedef QMap<int, QStringList> cookiepam;
cookiepam ActualCook;
/* each request i resend the cookie from last session phpsession id... or other */
QStringList resendcoo;
resendcoo.clear();
cookiepam ::Iterator it;
for ( it = ActualCook.begin(); it != ActualCook.end(); ++it ) {
QStringList resi = it.value();
QString name = resi.at(0);
QString oneci = QString("%1=%2").arg(name).arg(resi.at(1));
resendcoo.append(oneci);
}
header.setValue("Cookie",resendcoo.join(";"));
/* take cookie from header */
void RegisterCookie(const QHttpResponseHeader &responseHeader )
{
ActualCook.clear();
QStringList cookielist = responseHeader.allValues("set-cookie");
for (int i = 0; i < cookielist.size(); ++i) {
QString cokeline = cookielist.at(i);
QStringList onlines = cokeline.split("=");
QString cookiename = onlines.at(0);
QString cookievalue = onlines.at(1);
ActualCook.insert(i,QStringList() << cookiename << Url_Decode(cookievalue) << actualurl);
/////////////////qDebug() << "### entry set-cookie pos=" << i << " name= " << cookiename << " value=" << Url_Decode(cookievalue);
}
//////////emit WatReturn(QString("One code=%1 - Other say = %2 \n%3").arg( responseHeader.statusCode() ).arg( responseHeader.reasonPhrase() ).arg(CookieVars()) );
}
/* decode cookie value */
QString Base_Function::Url_Decode( QString indata )
{
/*
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
Dollar ("$") 24
Ampersand ("&") 26
Plus ("+") 2B
Comma (",") 2C
Forward slash/Virgule ("/") 2F
Colon (":") 3A
Semi-colon (";") 3B
Equals ("=") 3D
Question mark ("?") 3F
'At' symbol ("@") 40
Left Curly Brace ("{") 7B
Right Curly Brace ("}") 7D
Vertical Bar/Pipe ("|") 7C
Backslash ("\") 5C
Caret ("^") 5E
Tilde ("~") 7E
Left Square Bracket ("[") 5B
Right Square Bracket ("]") 5D
Grave Accent ("`") 60
*/
QString blnull = "";
QString notaccept = "%60|%5D|%5B|%7E|%5E|%5C|%7C|%7D|%7B";
QStringList notallow;
notallow = notaccept.split("|");
for (int i = 0; i < notallow.size(); ++i) {
if ( indata.contains(notallow.at(i)) ) {
return blnull;
}
}
QString spaceout = indata.replace("%20"," ");
spaceout = spaceout.replace("%3A",":");
spaceout = spaceout.replace("%3B",";");
spaceout = spaceout.replace("%3D","=");
spaceout = spaceout.replace("%2F","/");
spaceout = spaceout.replace("%3F","?");
spaceout = spaceout.replace("%40","@");
spaceout = spaceout.replace("%24","$");
spaceout = spaceout.replace("%2B","+");
spaceout = spaceout.replace("+"," ");
int zool = spaceout.indexOf(";",0);
return spaceout.left(zool);;
}
To copy to clipboard, switch view to plain text mode
Bookmarks