<html>
<head>
<script>
function onGet() {
var xhr = prepareRequest("GET");
xhr.send();
}
function prepareRequest(method) {
var url = document.getElementById("url");
var user = document.getElementById("user");
var password = document.getElementById("password");
var body = document.getElementById("body");
var xhr = new XMLHttpRequest();
xhr.open(method, url.value, false);
xhr.setRequestHeader("Authorization", "Basic " + window.btoa(user.value + ":" + password.value));
xhr.setRequestHeader("Accept", "application/xml");
xhr.setRequestHeader("Content-Type", "application/xml");
xhr.onload = function (e) {
var text = xhr.responseText;
body.value = text;
};
return xhr;
}
</script>
</head>
<body>
<form action="">
<table>
<tr>
<td>URL</td>
<td><input id="url" type="text" value="https://fedora.example.com/ovirt-engine/api"/></td>
</tr>
<tr>
<td>User</td>
<td><input id="user" type="text" value="admin@internal"/></td>
</tr>
<tr>
<td>Password</td>
<td><input id="password" type="password" value=""/></td>
</tr>
<tr>
<td colspan="2">
<div>
Body
</div>
<div>
<textarea id="body" rows="10" cols="80">
</textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" value="GET" onclick="onGet()"/>
</tr>
</table>
</form>
</body>
</html>