XMLHttpRequest and cookies ?



  • Hello,

    I appears that XMLHttpRequest does not seem to support cookies in the folling scenario:

    1. client send an authentified xmlhttprequest

    2. server sets various cookies for a '302 Found' (moved temporally)

    3. client re-connects to the next URL (same as the previous) and should send the cookies

    4. server actually serves the desired resource

    With QML, the scenario becomes:

    1.(same)

    2.(same)

    3: the client does not send the cookies

    4.the server and the client indefinitely loop on 2 + 3 until loop detection.

    I tried to subclass QNetworkManagerFactory and QNetworkCookieJar in C++ and launch the declarative viewer from C++ to permit cookies to be sent. However, the cookies are still not sent (verified with a tcp dump).

    I am out of idea.
    I am using Qt 4.7 git version (commit 8cb399e2c2ba47cdf3b27c7c5cb4d8d35702a068)
    Thanks for any idea and suggestions.



  • Moreover, it appears that XMLHttpRequest implementation in QML seem not to handle authentication, even if the request.withCredential is ste to true.

    Sniffing the network interface did not give me the autheticated reply from my QML script. while i gave user and password as parameter.

    Can someone confirm that authentication is not yet implemented in QML implementation of XMLHttpRequest ?



  • Hello,

    I work with brouits, author of this topic.

    We have found how to manage cookies by building a binary to use instead of qmlviewer. To do it we have subclassed QDeclarativeNetworkAccessManagerFactory.

    We still have problems with authentication. It seems that xmlHttpRequest does not take the "user" and "password" arguments into account. We bypassed this problem by putting credentials in the "Authorization" header, but we have to request data twice the first time because the call stops on the 401 HTTP Response.

    Any help will be greatly appreciated :-)



  • Hi,

    If these things are working correctly with other (e.g. webkit) xmlhttprequest implementations, then it is likely a bug in the QML implementation. Is it possible to provide an example or specific instructions to reproduce in the "bugtracker":http://bugreports.qt.nokia.com, so we can further track this down?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.