From 77e7981c69166f4d909eea9be3a84399d78a6d37 Mon Sep 17 00:00:00 2001
From: Yury Delendik <ydelendik@mozilla.com>
Date: Wed, 22 May 2013 13:11:50 -0500
Subject: [PATCH] Allows status be 0 for non-HTTP protocols

---
 src/network.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/network.js b/src/network.js
index 248cc8a0d..328c0f3f3 100644
--- a/src/network.js
+++ b/src/network.js
@@ -153,22 +153,24 @@ var NetworkManager = (function NetworkManagerClosure() {
 
       delete this.pendingRequests[xhrId];
 
-      if (xhr.status === 0) {
+      // success status == 0 can be on ftp, file and other protocols
+      if (xhr.status === 0 && /^https?:/i.test(this.url)) {
         if (pendingRequest.onError) {
           pendingRequest.onError(xhr.status);
         }
         return;
       }
+      var xhrStatus = xhr.status || OK_RESPONSE;
 
       // From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2:
       // "A server MAY ignore the Range header". This means it's possible to
       // get a 200 rather than a 206 response from a range request.
       var ok_response_on_range_request =
-          xhr.status === OK_RESPONSE &&
+          xhrStatus === OK_RESPONSE &&
           pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
 
       if (!ok_response_on_range_request &&
-          xhr.status !== pendingRequest.expectedStatus) {
+          xhrStatus !== pendingRequest.expectedStatus) {
         if (pendingRequest.onError) {
           pendingRequest.onError(xhr.status);
         }
@@ -178,7 +180,7 @@ var NetworkManager = (function NetworkManagerClosure() {
       this.loadedRequests[xhrId] = true;
 
       var chunk = getArrayBuffer(xhr);
-      if (xhr.status === PARTIAL_CONTENT_RESPONSE) {
+      if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
         var rangeHeader = xhr.getResponseHeader('Content-Range');
         var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
         var begin = parseInt(matches[1], 10);