1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
\r
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
\r
5 <title>REST API Test page</title>
\r
6 <script type="text/javascript" src="http://pajhome.org.uk/crypt/md5/sha1.js"></script>
\r
7 <script type="text/javascript">
\r
9 // Use strict RFC compliance
\r
12 var resource = decodeURI(document.getElementById("resource").value);
\r
13 var user = document.getElementById("user").value;
\r
14 var token = document.getElementById("token").value;
\r
15 var method = document.getElementById("method").value;
\r
16 var modified = document.getElementById("modified").value;
\r
17 var file = document.getElementById("file").value;
\r
18 var form = document.getElementById("form").value;
\r
19 var update = document.getElementById("update").value;
\r
21 var now = (new Date()).toUTCString();
\r
22 var q = resource.indexOf('?');
\r
23 var res = q == -1? resource: resource.substring(0, q);
\r
24 var data = method + now + res;
\r
25 var sig = b64_hmac_sha1(atob(token), data);
\r
31 var req = new XMLHttpRequest();
\r
32 req.open(method, '/gss/rest'+resource, true);
\r
33 req.onreadystatechange = function (event) {
\r
34 if (req.readyState == 4) {
\r
35 if(req.status == 200) {
\r
36 var result = document.getElementById("result");
\r
37 result.innerHTML = "<pre>"+req.getAllResponseHeaders()+"\n"+req.responseText+"</pre>";
\r
39 var result = document.getElementById("result");
\r
40 result.innerHTML = "<span style='color: red'>"+req.status+": "+req.statusText+"</span>"+"<pre>"+req.getAllResponseHeaders()+"</pre>";
\r
44 req.setRequestHeader("Authorization", user + " " + sig);
\r
45 req.setRequestHeader("X-GSS-Date", now);
\r
47 req.setRequestHeader("If-Modified-Since", modified);
\r
50 req.setRequestHeader("Content-Type", "text/plain");
\r
51 req.setRequestHeader("Content-Length", file.length);
\r
53 req.setRequestHeader("Content-Length", params.length);
\r
54 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
\r
55 } else if (update) {
\r
56 req.setRequestHeader("Content-Length", params.length);
\r
57 req.setRequestHeader("Content-Type", "application/json;");
\r
69 <tr><td>Resource </td><td><input id="resource" size="100"></td></tr>
\r
70 <tr><td>Method </td><td><input id="method"></td></tr>
\r
71 <tr><td>Username </td><td><input id="user"></td></tr>
\r
72 <tr><td>Auth token </td><td><input id="token" size="100"></td></tr>
\r
73 <tr><td>If-Modified-Since </td><td><input id="modified" size="100"></td></tr>
\r
74 <tr><td>File contents </td><td><input id="file" size="100"></td></tr>
\r
75 <tr><td>POST form </td><td><input id="form"></td></tr>
\r
76 <tr><td>POST JSON update </td><td><input id="update"></td></tr>
\r
78 <button onclick="send()">send</button><br>
\r
79 <div id="result" style="width: 200px; height: 200px"></div>
\r