timeouts?
This commit is contained in:
parent
40e9811ac8
commit
98618f6817
|
@ -54,7 +54,7 @@
|
||||||
#:servlet-path "/eval"))))
|
#:servlet-path "/eval"))))
|
||||||
|
|
||||||
(define (handle-poke req)
|
(define (handle-poke req)
|
||||||
;; FIXME: handle alarm for timeouts?
|
;; FIXME: how do we handle timeouts?
|
||||||
(let/ec return
|
(let/ec return
|
||||||
(let ([program (sync ch)]
|
(let ([program (sync ch)]
|
||||||
[op (open-output-bytes)])
|
[op (open-output-bytes)])
|
||||||
|
@ -111,10 +111,13 @@ EOF
|
||||||
<script>
|
<script>
|
||||||
// http://www.quirksmode.org/js/xmlhttp.html
|
// http://www.quirksmode.org/js/xmlhttp.html
|
||||||
//
|
//
|
||||||
|
// XMLHttpRequest wrapper. Transparently restarts the request
|
||||||
|
// if a timeout occurs.
|
||||||
function sendRequest(url,callback,postData) {
|
function sendRequest(url,callback,postData) {
|
||||||
var req = createXMLHTTPObject();
|
var req = createXMLHTTPObject(), method, TIMEOUT = 5000, stillInProgress = true, timeoutId;
|
||||||
|
|
||||||
if (!req) return;
|
if (!req) return;
|
||||||
var method = (postData) ? "POST" : "GET";
|
method = (postData) ? "POST" : "GET";
|
||||||
req.open(method,url,true);
|
req.open(method,url,true);
|
||||||
if (postData) {
|
if (postData) {
|
||||||
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
|
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
|
||||||
|
@ -124,10 +127,21 @@ function sendRequest(url,callback,postData) {
|
||||||
if (req.status !== 200 && req.status !== 304) {
|
if (req.status !== 200 && req.status !== 304) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
stillInProgress = false;
|
||||||
|
if (timeoutId) { clearTimeout(timeoutId); timeoutId = undefined; }
|
||||||
callback(req);
|
callback(req);
|
||||||
}
|
}
|
||||||
if (req.readyState == 4) return;
|
if (req.readyState == 4) return;
|
||||||
req.send(postData);
|
req.send(postData);
|
||||||
|
/*
|
||||||
|
timeoutId = setTimeout(function() { if(stillInProgress) {
|
||||||
|
req.abort();
|
||||||
|
// Reschedule
|
||||||
|
setTimeout(function() { sendRequest(url, callback, postData);}, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TIMEOUT);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
var XMLHttpFactories = [
|
var XMLHttpFactories = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user