blob: 6073692dea75573aed271129a6285dc0370447b2 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../org.dojotoolkit/dojo/dojo.js.uncompressed.js"></script>
<script type="text/javascript" src="../orion/plugin.js"></script>
<script>
window.onload = function() {
var provider = new eclipse.PluginProvider();
provider.registerServiceProvider("xhr", {
call : function(method, url, headers, message) {
var d = new dojo.Deferred(); // create a promise
var xhr = new XMLHttpRequest();
var header;
try {
xhr.open(method, url);
if (headers !== null) {
for (header in headers) {
if (headers.hasOwnProperty(header)) {
xhr.setRequestHeader(header, headers[header]);
}
}
}
xhr.send(message);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
d.resolve({
status: xhr.status,
statusText: xhr.statusText,
headers: xhr.getAllResponseHeaders(),
responseText: xhr.responseText
});
}
}
} catch (e) {
d.reject(e)
}
return d; // return the promise immediately
}
});
provider.connect();
};
</script>
</head>
<body>
</body>
</html>