Explorar el Código

catch HTTP 500/503 and empty response, fixes #141

jomo hace 9 años
padre
commit
b97087c099
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      lib/networking.js

+ 7 - 0
lib/networking.js

@@ -91,6 +91,8 @@ exp.get_from_options = function(rid, url, options, callback) {
         break;
         break;
       case 404:
       case 404:
       case 204:
       case 204:
+      case 500:
+      case 503:
         // we don't want to cache this
         // we don't want to cache this
         body = null;
         body = null;
         break;
         break;
@@ -107,6 +109,11 @@ exp.get_from_options = function(rid, url, options, callback) {
         break;
         break;
     }
     }
 
 
+    if (body && !body.length) {
+      // empty response
+      body = null;
+    }
+
     callback(body, response, error);
     callback(body, response, error);
   });
   });
 };
 };