diff options
author | 2009-04-23 16:13:02 -0400 | |
---|---|---|
committer | 2009-04-23 16:13:02 -0400 | |
commit | 42a6d61be0c529b52d16e34998e96183219aea65 (patch) | |
tree | 2034375ed7452282a9f1bbb4b3ee02f5bca63280 /lib/js/urweb.js | |
parent | 5ef3495dd44b076f46f4fdba4a021ea362116677 (diff) |
Cookie signatures for RPCs
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r-- | lib/js/urweb.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 877ed77f..a29914b9 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -353,7 +353,9 @@ function getXHR(uri) } } -function requestUri(xhr, uri) { +var sig = null; + +function requestUri(xhr, uri, needsSig) { xhr.open("GET", uri, true); if (client_id != null) { @@ -361,10 +363,17 @@ function requestUri(xhr, uri) { xhr.setRequestHeader("UrWeb-Pass", client_pass.toString()); } + if (needsSig) { + if (sig == null) + whine("Missing cookie signature!"); + + xhr.setRequestHeader("UrWeb-Sig", sig); + } + xhr.send(null); } -function rc(uri, parse, k) { +function rc(uri, parse, k, needsSig) { uri = flattenLocal(uri); var xhr = getXHR(); @@ -389,7 +398,7 @@ function rc(uri, parse, k) { } }; - requestUri(xhr, uri); + requestUri(xhr, uri, needsSig); } function path_join(s1, s2) { @@ -438,7 +447,7 @@ function listener() { var connect = function () { xhr.onreadystatechange = orsc; tid = window.setTimeout(onTimeout, timeout * 500); - requestUri(xhr, uri); + requestUri(xhr, uri, false); } orsc = function() { @@ -490,8 +499,8 @@ function listener() { } else { try { - servError("Error querying remote server for messages: " + xhr.status); - } catch (e) { servError("Error querying remote server for messages"); } + servErr("Error querying remote server for messages: " + xhr.status); + } catch (e) { servErr("Error querying remote server for messages"); } } } }; |