To grab cookie i make it so..... code down ....
grab check and resend ..... next session....

otherwise if i upload big file i use method PUT && PHP
is faster as post!

http://www.qtforum.de/forum/viewtopic.php?t=3085

and i send one virtual cookie nr. "2352Rt35j235-252Zu532kh5-3252" to autenficate on php script
and one cookie wo place to save file .... simply 10 line code...

Qt Code:
  1. typedef QMap<int, QStringList> cookiepam;
  2.  
  3. cookiepam ActualCook;
  4.  
  5. /* each request i resend the cookie from last session phpsession id... or other */
  6. QStringList resendcoo;
  7. resendcoo.clear();
  8. cookiepam ::Iterator it;
  9. for ( it = ActualCook.begin(); it != ActualCook.end(); ++it ) {
  10. QStringList resi = it.value();
  11. QString name = resi.at(0);
  12. QString oneci = QString("%1=%2").arg(name).arg(resi.at(1));
  13. resendcoo.append(oneci);
  14. }
  15. header.setValue("Cookie",resendcoo.join(";"));
  16.  
  17.  
  18.  
  19.  
  20. /* take cookie from header */
  21. void RegisterCookie(const QHttpResponseHeader &responseHeader )
  22. {
  23. ActualCook.clear();
  24. QStringList cookielist = responseHeader.allValues("set-cookie");
  25. for (int i = 0; i < cookielist.size(); ++i) {
  26. QString cokeline = cookielist.at(i);
  27. QStringList onlines = cokeline.split("=");
  28. QString cookiename = onlines.at(0);
  29. QString cookievalue = onlines.at(1);
  30. ActualCook.insert(i,QStringList() << cookiename << Url_Decode(cookievalue) << actualurl);
  31. /////////////////qDebug() << "### entry set-cookie pos=" << i << " name= " << cookiename << " value=" << Url_Decode(cookievalue);
  32. }
  33. //////////emit WatReturn(QString("One code=%1 - Other say = %2 \n%3").arg( responseHeader.statusCode() ).arg( responseHeader.reasonPhrase() ).arg(CookieVars()) );
  34. }
  35.  
  36. /* decode cookie value */
  37. QString Base_Function::Url_Decode( QString indata )
  38. {
  39. /*
  40. http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
  41. Dollar ("$") 24
  42. Ampersand ("&") 26
  43. Plus ("+") 2B
  44. Comma (",") 2C
  45. Forward slash/Virgule ("/") 2F
  46. Colon (":") 3A
  47. Semi-colon (";") 3B
  48. Equals ("=") 3D
  49. Question mark ("?") 3F
  50. 'At' symbol ("@") 40
  51. Left Curly Brace ("{") 7B
  52. Right Curly Brace ("}") 7D
  53. Vertical Bar/Pipe ("|") 7C
  54. Backslash ("\") 5C
  55. Caret ("^") 5E
  56. Tilde ("~") 7E
  57. Left Square Bracket ("[") 5B
  58. Right Square Bracket ("]") 5D
  59. Grave Accent ("`") 60
  60. */
  61. QString blnull = "";
  62. QString notaccept = "%60|%5D|%5B|%7E|%5E|%5C|%7C|%7D|%7B";
  63. QStringList notallow;
  64. notallow = notaccept.split("|");
  65.  
  66. for (int i = 0; i < notallow.size(); ++i) {
  67. if ( indata.contains(notallow.at(i)) ) {
  68. return blnull;
  69. }
  70. }
  71.  
  72. QString spaceout = indata.replace("%20"," ");
  73. spaceout = spaceout.replace("%3A",":");
  74. spaceout = spaceout.replace("%3B",";");
  75. spaceout = spaceout.replace("%3D","=");
  76. spaceout = spaceout.replace("%2F","/");
  77. spaceout = spaceout.replace("%3F","?");
  78. spaceout = spaceout.replace("%40","@");
  79. spaceout = spaceout.replace("%24","$");
  80. spaceout = spaceout.replace("%2B","+");
  81. spaceout = spaceout.replace("+"," ");
  82. int zool = spaceout.indexOf(";",0);
  83. return spaceout.left(zool);;
  84. }
To copy to clipboard, switch view to plain text mode