Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativexmlhttprequest / data / setRequestHeader_sent.qml
1 import QtQuick 1.0
2
3 QtObject {
4     property string url
5     property bool test: false
6
7     property bool dataOK: false
8
9     Component.onCompleted: {
10         var x = new XMLHttpRequest;
11
12         x.open("GET", url);
13         x.setRequestHeader("Accept-Language","en-US");
14
15         // Test to the end
16         x.onreadystatechange = function() {
17             if (x.readyState == XMLHttpRequest.DONE) {
18                 dataOK = (x.responseText == "QML Rocks!\n");
19             }
20         }
21
22         x.send();
23
24         try {
25             x.setRequestHeader("Test-header", "value");
26         } catch (e) {
27             if (e.code == DOMException.INVALID_STATE_ERR)
28                 test = true;
29         }
30     }
31 }
32