From 3c03a42d1edb0ec26110ace00f42e156cabff67b Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 9 Dec 2006 09:17:22 +0000 Subject: Fixed #433, #384, #439, #477, #435, #422, #401, #359. Add more class docs for sqlmap. --- framework/Web/Javascripts/prado/ajax3.js | 113 ++++++++++++++----------------- 1 file changed, 52 insertions(+), 61 deletions(-) (limited to 'framework/Web/Javascripts/prado/ajax3.js') diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js index c5402ea4..f540813c 100644 --- a/framework/Web/Javascripts/prado/ajax3.js +++ b/framework/Web/Javascripts/prado/ajax3.js @@ -14,6 +14,9 @@ Object.extend(Ajax.Request.prototype, if (event == 'Complete') { + if(this.header('X-PRADO-REDIRECT')) + document.location.href = this.header('X-PRADO-REDIRECT'); + if ((this.header('Content-type') || '').match(/^text\/javascript/i)) { try @@ -119,10 +122,6 @@ Object.extend(Prado.CallbackRequest, * Page state header name. */ PAGESTATE_HEADER : 'X-PRADO-PAGESTATE', - /** - * Current requests in progress. - */ - currentRequest : null, requestQueue : [], @@ -264,25 +263,6 @@ Object.extend(Prado.CallbackRequest, return null; }, - /** - * Dispatch a priority request, it will call abortRequestInProgress first. - */ - dispatchPriorityRequest : function(callback) - { - var self = Prado.CallbackRequest; - - callback.request = new Ajax.Request(callback.url, callback.options); - callback.timeout = setTimeout(function() - { - //Logger.warn("priority timeout"); - self.abortCurrentRequest(); - },callback.options.RequestTimeOut); - - //Logger.info("dispatched "+this.currentRequest) - self.currentRequest = callback; - return true; - }, - /** * Dispatch a normal request, no timeouts or aborting of requests. */ @@ -296,23 +276,19 @@ Object.extend(Prado.CallbackRequest, /** * Abort the current priority request in progress. */ - abortCurrentRequest : function() + tryNextRequest : function() { var self = Prado.CallbackRequest; - var inProgress = self.currentRequest; - //Logger.info("aborting ... "+inProgress); - if(inProgress) + //Logger.debug('trying next request'); + if(typeof(self.currentRequest) == 'undefined' || self.currentRequest==null) { - clearTimeout(inProgress.timeout); - self.currentRequest = null; - //Logger.info("aborted"); - //abort if not ready. - if(inProgress.request.transport.readyState < 4) - inProgress.request.transport.abort(); - return self.dispatchQueue(); + if(self.requestQueue.length > 0) + return self.dispatchQueue(); + //else + //Logger.warn('empty queque'); } - else - return self.dispatchQueue(); +// else + // Logger.warn('current request ' + self.currentRequest.id); }, /** @@ -334,51 +310,66 @@ Object.extend(Prado.CallbackRequest, { if(typeof(Logger) != "undefined") Logger.warn("Missing page state:"+data); +// Logger.warn('## bad state: setting current request to null'); + self.endCurrentRequest(); + //self.tryNextRequest(); return false; } } + self.endCurrentRequest(); + // Logger.warn('## state updated: setting current request to null'); + // self.tryNextRequest(); return true; }, enqueue : function(callback) { var self = Prado.CallbackRequest; - if(self.currentRequest==null) - self.dispatchPriorityRequest(callback); - else - self.requestQueue.push(callback); - //Logger.info("current queque length="+self.requestQueue.length); + self.requestQueue.push(callback); + //Logger.warn("equeued "+callback.id+", current queque length="+self.requestQueue.length); + self.tryNextRequest(); }, dispatchQueue : function() { var self = Prado.CallbackRequest; - //Logger.info("dispatching queque, length="+self.requestQueue.length+" request="+self.currentRequest); - if(self.requestQueue.length > 0) + //Logger.warn("dispatching queque, length="+self.requestQueue.length+" request="+self.currentRequest); + var callback = self.requestQueue.shift(); + self.currentRequest = callback; + + //get data + callback.options.postBody = callback._getPostData(), + + callback.request = new Ajax.Request(callback.url, callback.options); + callback.timeout = setTimeout(function() { - var callback = self.requestQueue.shift(); - //Logger.info("do dispatch request"); - return self.dispatchPriorityRequest(callback); - } - return false; + //Logger.warn("priority timeout"); + self.abortRequest(callback.id); + },callback.options.RequestTimeOut); + //Logger.debug("dispatched "+self.currentRequest.id + " ...") + }, + + endCurrentRequest : function() + { + var self = Prado.CallbackRequest; + clearTimeout(self.currentRequest.timeout); + self.currentRequest=null; }, abortRequest : function(id) { - //Logger.info("abort id="+id); + //Logger.warn("abort id="+id); var self = Prado.CallbackRequest; - if(self.currentRequest != null && self.currentRequest.id == id) - self.abortCurrentRequest(); - else + if(typeof(self.currentRequest) != 'undefined' + && self.currentRequest != null && self.currentRequest.id == id) { - var queque = []; - self.requestQueue.each(function(callback) - { - if(callback.id != id) - queque.push(callback); - }); - self.requestQueue = queque; + var request = self.currentRequest.request; + if(request.transport.readyState < 4) + request.transport.abort(); + //Logger.warn('## aborted: setting current request to null'); + self.endCurrentRequest(); } + self.tryNextRequest(); } }) @@ -388,7 +379,7 @@ Object.extend(Prado.CallbackRequest, Ajax.Responders.register({onComplete : function(request) { if(request.options.HasPriority) - Prado.CallbackRequest.abortCurrentRequest(); + Prado.CallbackRequest.tryNextRequest(); }}); //Add HTTP exception respones when logger is enabled. @@ -528,7 +519,7 @@ Prado.CallbackRequest.prototype = //override parameter and postBody options. Object.extend(this.options, { - postBody : this._getPostData(), +// postBody : this._getPostData(), parameters : '' }); -- cgit v1.2.3