Page 2 of 2 FirstFirst 12
Results 21 to 34 of 34

Thread: I get only 1 of 4 cookies...

  1. #21
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    Aaaammm "No, it makes it QList<QVariant>............ (because it is not a QList<QVariant>)." ?

  2. #22
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    Quote Originally Posted by cherva View Post
    Aaaammm "No, it makes it QList<QVariant>............ (because it is not a QList<QVariant>)." ?
    I suggest you rephrase this post because I have no idea what you mean. If it's that you don't see a difference between QVariant and QNetworkCookie then I suggest you click both links and read the docs to see the differences. You are trying to convert a QVariant holding a QList<QNetworkCookie> into QList<QVariant> which it is not thus you get an empty QList<QVariant>. It's like you wanted to convert a rectangle into a circle - you'd get an invalid circle because rectangles can't be converted to circles without actually knowing what a "rectangles" and "circles" are.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #23
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    I didn't understand what he posted.... at firs he says that it's a QList<QVariant> and then in the brackets he says that it's not QList<QVariant>, but never mind that. I don't know how to convert it to a QList<QNetworkCookie> ? I guess not like
    Qt Code:
    1. QList<QNetworkCookie> list = cookies.toList();
    To copy to clipboard, switch view to plain text mode 

  4. #24
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    Quote Originally Posted by cherva View Post
    at firs he says that it's a QList<QVariant>
    No, at first "he" says the cast tries to make it QList<QVariant>.

    and then in the brackets he says that it's not QList<QVariant>,
    Yes, so "he" says.

    but never mind that.
    Actually you should mind because it is the most important part of the whole discussion.

    I don't know how to convert it to a QList<QNetworkCookie> ? I guess not like
    Qt Code:
    1. QList<QNetworkCookie> list = cookies.toList();
    To copy to clipboard, switch view to plain text mode 
    I guess the compiler already told you it is not the right route...

    Try this:
    Qt Code:
    1. QList<QNetworkCookie> cookieList = qvariant_cast<QList<QNetworkCookie> >(cookies);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #25
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    I don't know how to explain what happened...
    My cookieList has 1 item: "d" wich is a QSharedDataPointer<QNetworkCookiePrivate> wich has another "d" wich is QNetworkCookiePrivate * with value 0x1 there is *d inside it wich is QNetworkCookiePrivate and insite that there is a QSharedData (commend,domain,expirationDate,httpOnly,name,path, secure,value) and they are all "not in scope"

  6. #26
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    Quote Originally Posted by cherva View Post
    I don't know how to explain what happened...
    You tried debugging a class your debugger has no support for. That's normal. Forget the debugger - after making the cast see the size of the list. If it is 0 then it's not a list but rather a QNetworkCookie object which would be strange. Try running this code (assuming "rep" is your QNetworkReply object):

    Qt Code:
    1. QVariant var = rep->header(QNetworkRequest::SetCookieHeader);
    2. qDebug() << "Cookies set:" << var;
    3. QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie> >(var);
    4. foreach(QNetworkCookie c, cookies){
    5. qDebug() << QString(c.toRawForm());
    6. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #27
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    Again it's only one cookie. The JSESSIONID.

  8. #28
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    Quote Originally Posted by cherva View Post
    Again it's only one cookie. The JSESSIONID.
    Great, finally... Now you should check if setting multiple set-cookie headers is a valid policy with HTTP/1.1. If so then probably reporting a bug to Qt Software is a good idea. If not, then you have to find a workaround for the faulty server for instance using QNetworkReply::rawHeaderList() and QNetworkCookie::parseCookies().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #29
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: I get only 1 of 4 cookies...

    From RFC 2109, "An origin server may include multiple Set-Cookie headers in a response. Note that an intervening gateway could fold multiple such headers into a single header."

    Servers do return multiple Set-Cookie lines, for example (wrapping of line 10 is mine):
    Qt Code:
    1. Resolving www.doubleclick.com... 216.73.93.8
    2. Connecting to www.doubleclick.com|216.73.93.8|:80... connected.
    3. HTTP request sent, awaiting response...
    4. HTTP/1.1 200 OK
    5. Connection: keep-alive
    6. Date: Tue, 05 May 2009 08:43:11 GMT
    7. Server: Microsoft-IIS/6.0
    8. X-Powered-By: ASP.NET
    9. X-AspNet-Version: 2.0.50727
    10. Set-Cookie: ecm=user_id=0&isMembershipUser=0&site_id=&username=&new_site=/
    11. &unique_id=0&site_preview=0&langvalue=0&DefaultLanguage=1033&NavLanguage=1033&
    12. LastValidLanguageID=1033&ContType=&UserCulture=1033&SiteLanguage=1033; path=/
    13. Set-Cookie: ASP.NET_SessionId=arv3wz3p3eqaayff0d1duv45; path=/; HttpOnly
    14. Cache-Control: private
    15. Content-Type: text/html; charset=utf-8
    16. Content-Length: 30533
    17. Length: 30533 (30K) [text/html]
    To copy to clipboard, switch view to plain text mode 

  10. #30
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    I sent a bug report to QT. QNetworkReply::rawHeaderList() tells me that there is only one Set-Cookie ..... I think it is affected too. Can I dump the header to a QByteArray and cut the part I don't need ?

  11. #31
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    You can dump whatever you want wherever you want if there is an API call for that. Unfortunately I don't see means to do that in the API.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #32
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    Anyone having other ideas ?

  13. #33
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: I get only 1 of 4 cookies...

    Quote Originally Posted by cherva View Post
    Anyone having other ideas ?
    You can use QHttp or even QTcpSocket or implement a workaround in Qt itself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #34
    Join Date
    May 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I get only 1 of 4 cookies...

    For anyone having the same issue this problem is fixed in QT 4.5.2 and UP.
    Thanks ChrisW67, and wysota.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.