revert [10347] which causes double requests in certain conditions, discussed in #2065, r=ahocevar

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10426 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2010-06-28 07:16:37 +00:00
parent 60e869e295
commit 0b9e0f50ab
3 changed files with 30 additions and 4 deletions

View File

@@ -161,8 +161,18 @@ OpenLayers.Request = {
} }
}; };
request.send(config.data); // send request (optionally with data) and return
// call in a timeout for asynchronous requests so the return is
// available before readyState == 4 for cached docs
if(config.async === false) {
request.send(config.data);
} else {
window.setTimeout(function(){
if (request._aborted !== true) {
request.send(config.data);
}
}, 0);
}
return request; return request;
}, },

View File

@@ -128,7 +128,7 @@
// //
fCleanTransport(oRequest); fCleanTransport(oRequest);
// Uncomment this block if you need a fix for IE cache // Uncomment this block if you need a fix for IE cache
/**/ /*
// BUGFIX: IE - cache issue // BUGFIX: IE - cache issue
if (!oRequest._object.getResponseHeader("Date")) { if (!oRequest._object.getResponseHeader("Date")) {
// Save object to cache // Save object to cache
@@ -192,7 +192,7 @@
// Return now - wait until re-sent request is finished // Return now - wait until re-sent request is finished
return; return;
}; };
/**/ */
// BUGFIX: IE - memory leak in interrupted // BUGFIX: IE - memory leak in interrupted
if (bIE && bAsync) if (bIE && bAsync)
window.detachEvent("onunload", fOnUnload); window.detachEvent("onunload", fOnUnload);

View File

@@ -371,6 +371,22 @@
teardown(); teardown();
} }
function test_abort(t) {
t.plan(0);
var fail = false;
OpenLayers.Request.XMLHttpRequest.onsend = function(args) {
fail = true;
}
t.delay_call(0.5, function() {
if (fail === true) {
t.fail("Send should not be called because request is aborted");
}
OpenLayers.Request.XMLHttpRequest.onsend = null;
});
var protocol = new OpenLayers.Protocol.HTTP();
protocol.abort(protocol.read());
}
</script> </script>
</head> </head>
<body> <body>