On Tue, Oct 18, 2011 at 6:13 PM, Johan Paul <[email protected]> wrote:
> HTTP Auth is your traditional browser popup to log in to sites with.
> AFAIK there is no way to do this in QML right now. But I would also like
> to be proven wrong (or hear it's available in QtQuick2).

QML's XHR implements the good old W3C API which has support for HTTP
authentication. Just pass the username and password as parameters in
the call to send().

import QtQuick 1.0

Item
{
    width: 400
    height: 400

    MouseArea {
        anchors.fill: parent
        onClicked: {
             var doc = new XMLHttpRequest();
             doc.onreadystatechange = function() {
                 if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
                     console.log("Headers:");
                     console.log(doc.getAllResponseHeaders());

                 } else if (doc.readyState == XMLHttpRequest.DONE) {
                     console.log("Response:");
                     console.log(doc.responseText);
                 }
             }

             doc.open("GET",
"http://koivi.com/php-http-auth/protect.php";, true, "tester",
"testing");
             doc.send();
        }
    }
}
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to