aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlxmlhttprequest/data/send_patch.qml
blob: d7d57b445ca3b18207686770a4237502ff2de457 (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
33
34
35
36
37
// Copyright (C) 2017 Canonical Limited and/or its subsidiary(-ies).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick 2.0

QtObject {
    property string url

    property bool dataOK: false
    property bool headerOK: false

    Component.onCompleted: {
        var x = new XMLHttpRequest;
        x.open("PATCH", url);
        x.setRequestHeader("If-Match","\"ETagNumber\"");

        // Test to the end
        x.onreadystatechange = function() {
            if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
                headerOK = (x.getResponseHeader("Content-Location") == "/qqmlxmlhttprequest.cpp") &&
                    (x.getResponseHeader("ETag") == "\"ETagNumber\"") &&
                    (x.status == "204");
            } else if (x.readyState == XMLHttpRequest.DONE) {
                dataOK = (x.responseText === "");
            }
        }

        var body = "--- a/qqmlxmlhttprequest.cpp\n" +
            "+++ b/qqmlxmlhttprequest.cpp\n" +
            "@@ -1238,11 +1238,13 @@\n" +
            "-    } else if (m_method == QLatin1String(\"OPTIONS\")) {\n" +
            "+    } else if (m_method == QLatin1String(\"OPTIONS\") ||\n" +
            "+            (m_method == QLatin1String(\"PATCH\"))) {\n"

        x.send(body);
    }
}