aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlxmlhttprequest/data/file_request.qml
blob: 51020c185ec30335ab9e15fec0fa6714b97d489b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import QtQuick 2.0

QtObject {
    // Inputs

    id: root

    property string writeURL
    property string readURL
    // Outputs
    property bool writeDone: false
    property variant readResult

    Component.onCompleted: {
        // PUT
        var xhrWrite = new XMLHttpRequest;
        xhrWrite.open("PUT", writeURL);
        xhrWrite.onreadystatechange = function() {
            if (xhrWrite.readyState === XMLHttpRequest.DONE)
                writeDone = true;
        };
        xhrWrite.send("Test-String");
        // GET
        var xhrRead = new XMLHttpRequest;
        xhrRead.open("GET", readURL);
        xhrRead.onreadystatechange = function() {
            if (xhrRead.readyState === XMLHttpRequest.DONE)
                readResult = xhrRead.responseText;
        };
        xhrRead.send();
    }
}