blob: 35a629fc925ecd2d0dd72881d41b39da3fc2a68e (
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
38
|
// Copyright (C) 2017 Canonical Limited and/or its subsidiary(-ies).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
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("Accept-Language","en-US");
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);
}
}
|