Commit 7cbf851f96d08768b3d40d1d6123655508acb65c
1 parent
7a6af063
Exists in
master
and in
7 other branches
incluida opção de verificação de timeout no servidor
Showing
2 changed files
with
41 additions
and
9 deletions
Show diff stats
pacotes/cpaint/cpaint2.inc.compressed.js
@@ -43,7 +43,19 @@ if(httpobj.readyState!=4){httpobj.abort();} | @@ -43,7 +43,19 @@ if(httpobj.readyState!=4){httpobj.abort();} | ||
43 | return return_value;} | 43 | return return_value;} |
44 | var callback=function(){var response=null;if(httpobj.readyState==4&&httpobj.status==200){debug(httpobj.responseText,1);debug('using response type '+config['response_type'],2);switch(config['response_type']){case'XML':debug(httpobj.responseXML,2);response=__cpaint_transformer.xml_conversion(httpobj.responseXML);break;case'OBJECT':response=__cpaint_transformer.object_conversion(httpobj.responseXML);break;case'TEXT':response=__cpaint_transformer.text_conversion(httpobj.responseText);break;case'E4X':response=__cpaint_transformer.e4x_conversion(httpobj.responseText);break;case'JSON':response=__cpaint_transformer.json_conversion(httpobj.responseText);break;default:debug('invalid response type \''+response_type+'\'',0);} | 44 | var callback=function(){var response=null;if(httpobj.readyState==4&&httpobj.status==200){debug(httpobj.responseText,1);debug('using response type '+config['response_type'],2);switch(config['response_type']){case'XML':debug(httpobj.responseXML,2);response=__cpaint_transformer.xml_conversion(httpobj.responseXML);break;case'OBJECT':response=__cpaint_transformer.object_conversion(httpobj.responseXML);break;case'TEXT':response=__cpaint_transformer.text_conversion(httpobj.responseText);break;case'E4X':response=__cpaint_transformer.e4x_conversion(httpobj.responseText);break;case'JSON':response=__cpaint_transformer.json_conversion(httpobj.responseText);break;default:debug('invalid response type \''+response_type+'\'',0);} |
45 | if(response!=null&&typeof client_callback=='function'){client_callback(response,httpobj.responseText);} | 45 | if(response!=null&&typeof client_callback=='function'){client_callback(response,httpobj.responseText);} |
46 | -remove_from_stack();}else if(httpobj.readyState==4&&httpobj.status!=200){debug('invalid HTTP response code \''+Number(httpobj.status)+'\'',0);client_callback("", "erro");}} | 46 | +remove_from_stack();} |
47 | +else | ||
48 | +if(httpobj.readyState==4&&httpobj.status!=200) | ||
49 | +{ | ||
50 | + debug('invalid HTTP response code \''+Number(httpobj.status)+'\'',0); | ||
51 | + if(httpobj.status==500){ | ||
52 | + alert("O servidor demorou muito - timout"); | ||
53 | + client_callback("", "erro"); | ||
54 | + } | ||
55 | + else | ||
56 | + client_callback("", "erro"); | ||
57 | +} | ||
58 | +} | ||
47 | var remove_from_stack=function(){if(typeof stack_id=='number'&&__cpaint_stack[stack_id]&&config['persistent_connection']==false){__cpaint_stack[stack_id]=null;}} | 59 | var remove_from_stack=function(){if(typeof stack_id=='number'&&__cpaint_stack[stack_id]&&config['persistent_connection']==false){__cpaint_stack[stack_id]=null;}} |
48 | var debug=function(message,debug_level){var prefix='[CPAINT Debug] ';if(config['debugging']<1){prefix='[CPAINT Error] ';if (message.search(" error") > 1){client_callback("", message);}} | 60 | var debug=function(message,debug_level){var prefix='[CPAINT Debug] ';if(config['debugging']<1){prefix='[CPAINT Error] ';if (message.search(" error") > 1){client_callback("", message);}} |
49 | if(config['debugging']>=debug_level){alert(prefix+message);}}} | 61 | if(config['debugging']>=debug_level){alert(prefix+message);}}} |
pacotes/cpaint/cpaint2.inc.js
@@ -699,10 +699,13 @@ function cpaint_call() { | @@ -699,10 +699,13 @@ function cpaint_call() { | ||
699 | */ | 699 | */ |
700 | var callback = function() { | 700 | var callback = function() { |
701 | var response = null; | 701 | var response = null; |
702 | - | ||
703 | if (httpobj.readyState == 4 | 702 | if (httpobj.readyState == 4 |
704 | && httpobj.status == 200) { | 703 | && httpobj.status == 200) { |
705 | - | 704 | + if(httpobj.responseText == ""){ |
705 | + alert("O servidor demorou muito - timeout"); | ||
706 | + client_callback("", "erro"); | ||
707 | + return; | ||
708 | + } | ||
706 | debug(httpobj.responseText, 1); | 709 | debug(httpobj.responseText, 1); |
707 | debug('using response type ' + config['response_type'], 2); | 710 | debug('using response type ' + config['response_type'], 2); |
708 | 711 | ||
@@ -736,16 +739,33 @@ function cpaint_call() { | @@ -736,16 +739,33 @@ function cpaint_call() { | ||
736 | // call client side callback | 739 | // call client side callback |
737 | if (response != null | 740 | if (response != null |
738 | && typeof client_callback == 'function') { | 741 | && typeof client_callback == 'function') { |
739 | - client_callback(response, httpobj.responseText); | 742 | + try{ |
743 | + if(response.data) | ||
744 | + client_callback(response, httpobj.responseText); | ||
745 | + else | ||
746 | + client_callback("", "erro"); | ||
747 | + } | ||
748 | + catch(e){ | ||
749 | + client_callback("", "erro"); | ||
750 | + } | ||
740 | } | 751 | } |
741 | // remove ourselves from the stack | 752 | // remove ourselves from the stack |
742 | remove_from_stack(); | 753 | remove_from_stack(); |
743 | 754 | ||
744 | - } else if (httpobj.readyState == 4 | ||
745 | - && httpobj.status != 200) { | ||
746 | - // HTTP error of some kind | ||
747 | - debug('invalid HTTP response code \'' + Number(httpobj.status) + '\'', 0); | ||
748 | - //client_callback("", ""); | 755 | + } else |
756 | + { | ||
757 | + if(httpobj.readyState==4&&httpobj.status!=200) | ||
758 | + { | ||
759 | + debug('invalid HTTP response code \''+Number(httpobj.status)+'\'',0); | ||
760 | + if(httpobj.status==500){ | ||
761 | + alert("O servidor demorou muito - timeout"); | ||
762 | + client_callback("", "erro"); | ||
763 | + } | ||
764 | + else{ | ||
765 | + client_callback("", "erro"); | ||
766 | + } | ||
767 | + } | ||
768 | + | ||
749 | } | 769 | } |
750 | } | 770 | } |
751 | 771 |