diff options
author | thomascube <thomas@roundcube.net> | 2012-05-01 07:04:40 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2012-05-01 07:04:40 +0000 |
commit | 110360772101c4c53ffff678d89b9d932d7c2716 (patch) | |
tree | aab9da477cd2d86bfef7d1c3ca36f4e7bed2e420 /program | |
parent | 58154f59fc16322598e3a01937fbffdb97cdf62b (diff) |
Better handling of HTTP request errors; re-send keep-alive requests on failure (#1488449)
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcmail.php | 2 | ||||
-rw-r--r-- | program/js/app.js | 40 | ||||
-rw-r--r-- | program/localization/de_CH/messages.inc | 1 | ||||
-rw-r--r-- | program/localization/de_DE/messages.inc | 1 | ||||
-rw-r--r-- | program/localization/en_US/messages.inc | 1 |
5 files changed, 21 insertions, 24 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php index e70980137..bd21ca8a2 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -325,7 +325,7 @@ class rcmail extends rcube $this->output->set_charset(RCMAIL_CHARSET); // add some basic labels to client - $this->output->add_label('loading', 'servererror'); + $this->output->add_label('loading', 'servererror', 'requesttimedout'); return $this->output; } diff --git a/program/js/app.js b/program/js/app.js index 12c542615..c440d169e 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -54,9 +54,10 @@ function rcube_webmail() // set jQuery ajax options $.ajaxSetup({ - cache:false, - error:function(request, status, err){ ref.http_error(request, status, err); }, - beforeSend:function(xmlhttp){ xmlhttp.setRequestHeader('X-Roundcube-Request', ref.env.request_token); } + cache: false, + timeout: this.env.request_timeout * 1000, + error: function(request, status, err){ ref.http_error(request, status, err); }, + beforeSend: function(xmlhttp){ xmlhttp.setRequestHeader('X-Roundcube-Request', ref.env.request_token); } }); // set environment variable(s) @@ -955,8 +956,6 @@ function rcube_webmail() form.action = this.add_url(form.action, '_lang', lang); form.submit(); - // clear timeout (sending could take longer) - clearTimeout(this.request_timer); break; case 'send-attachment': @@ -1158,14 +1157,6 @@ function rcube_webmail() if (this.gui_objects.editform) this.lock_form(this.gui_objects.editform, a); - // clear pending timer - if (this.request_timer) - clearTimeout(this.request_timer); - - // set timer for requests - if (a && this.env.request_timeout) - this.request_timer = setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000); - return id; }; @@ -1204,13 +1195,6 @@ function rcube_webmail() return url.replace(/_task=[a-z]+/, '_task='+task); }; - // called when a request timed out - this.request_timed_out = function() - { - this.set_busy(false); - this.display_message('Request timed out!', 'error'); - }; - this.reload = function(delay) { if (this.is_framed()) @@ -5997,7 +5981,7 @@ function rcube_webmail() return $.ajax({ type: 'GET', url: url, data: { _unlock:(lock?lock:0) }, dataType: 'json', success: function(data){ ref.http_response(data); }, - error: function(o, status, err) { rcmail.http_error(o, status, err, lock); } + error: function(o, status, err) { ref.http_error(o, status, err, lock, action); } }); }; @@ -6029,7 +6013,7 @@ function rcube_webmail() return $.ajax({ type: 'POST', url: url, data: postdata, dataType: 'json', success: function(data){ ref.http_response(data); }, - error: function(o, status, err) { rcmail.http_error(o, status, err, lock); } + error: function(o, status, err) { ref.http_error(o, status, err, lock, action); } }); }; @@ -6161,7 +6145,7 @@ function rcube_webmail() }; // handle HTTP request errors - this.http_error = function(request, status, err, lock) + this.http_error = function(request, status, err, lock, action) { var errmsg = request.statusText; @@ -6170,6 +6154,16 @@ function rcube_webmail() if (request.status && errmsg) this.display_message(this.get_label('servererror') + ' (' + errmsg + ')', 'error'); + else if (status == 'timeout') + this.display_message(this.get_label('requesttimedout'), 'error'); + else if (request.status == 0 && status != 'abort') + this.display_message(this.get_label('servererror') + ' (No connection)', 'error'); + + // re-send keep-alive requests after 30 seconds + if (action == 'keep-alive') + setTimeout(function(){ ref.keep_alive(); }, 30000); + else if (action == 'check-recent') + setTimeout(function(){ ref.check_for_recent(false); }, 30000); }; // post the given form to a hidden iframe diff --git a/program/localization/de_CH/messages.inc b/program/localization/de_CH/messages.inc index fd99142f6..2260ba089 100644 --- a/program/localization/de_CH/messages.inc +++ b/program/localization/de_CH/messages.inc @@ -23,6 +23,7 @@ $messages['storageerror'] = 'Keine Verbindung zum IMAP Server'; $messages['servererror'] = 'Serverfehler!'; $messages['servererrormsg'] = 'Serverfehler: $msg'; $messages['dberror'] = 'Datenbankfehler!'; +$messages['requesttimedout'] = 'Zeitlimit überschritten'; $messages['errorreadonly'] = 'Die Aktion kann nicht ausgeführt werden. Der Ordner ist schreibgeschützt.'; $messages['errornoperm'] = 'Die Aktion kann nicht ausgeführt werden. Zugriff verweigert.'; $messages['invalidrequest'] = 'Ungültige Anfrage! Es wurden keine Daten gespeichert.'; diff --git a/program/localization/de_DE/messages.inc b/program/localization/de_DE/messages.inc index 061d8920a..d6713917e 100644 --- a/program/localization/de_DE/messages.inc +++ b/program/localization/de_DE/messages.inc @@ -23,6 +23,7 @@ $messages['storageerror'] = 'Keine Verbindung zum IMAP Server.'; $messages['servererror'] = 'Serverfehler!'; $messages['servererrormsg'] = 'Serverfehler: $msg'; $messages['dberror'] = 'Datenbankfehler!'; +$messages['requesttimedout'] = 'Zeitlimit überschritten'; $messages['errorreadonly'] = 'Die Aktion kann nicht ausgeführt werden. Der Ordner ist schreibgeschützt.'; $messages['errornoperm'] = 'Die Aktion kann nicht ausgeführt werden. Zugriff verweigert.'; $messages['invalidrequest'] = 'Ungültige Anfrage! Es wurden keine Daten gespeichert.'; diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index 7125c1451..779c41660 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -29,6 +29,7 @@ $messages['storageerror'] = 'Connection to storage server failed.'; $messages['servererror'] = 'Server Error!'; $messages['servererrormsg'] = 'Server Error: $msg'; $messages['dberror'] = 'Database Error!'; +$messages['requesttimedout'] = 'Request timed out'; $messages['errorreadonly'] = 'Unable to perform operation. Folder is read-only.'; $messages['errornoperm'] = 'Unable to perform operation. Permission denied.'; $messages['invalidrequest'] = 'Invalid request! No data was saved.'; |