Allows status be 0 for non-HTTP protocols
This commit is contained in:
parent
869b8788ab
commit
77e7981c69
@ -153,22 +153,24 @@ var NetworkManager = (function NetworkManagerClosure() {
|
|||||||
|
|
||||||
delete this.pendingRequests[xhrId];
|
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) {
|
if (pendingRequest.onError) {
|
||||||
pendingRequest.onError(xhr.status);
|
pendingRequest.onError(xhr.status);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var xhrStatus = xhr.status || OK_RESPONSE;
|
||||||
|
|
||||||
// From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2:
|
// 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
|
// "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.
|
// get a 200 rather than a 206 response from a range request.
|
||||||
var ok_response_on_range_request =
|
var ok_response_on_range_request =
|
||||||
xhr.status === OK_RESPONSE &&
|
xhrStatus === OK_RESPONSE &&
|
||||||
pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
|
pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
|
||||||
|
|
||||||
if (!ok_response_on_range_request &&
|
if (!ok_response_on_range_request &&
|
||||||
xhr.status !== pendingRequest.expectedStatus) {
|
xhrStatus !== pendingRequest.expectedStatus) {
|
||||||
if (pendingRequest.onError) {
|
if (pendingRequest.onError) {
|
||||||
pendingRequest.onError(xhr.status);
|
pendingRequest.onError(xhr.status);
|
||||||
}
|
}
|
||||||
@ -178,7 +180,7 @@ var NetworkManager = (function NetworkManagerClosure() {
|
|||||||
this.loadedRequests[xhrId] = true;
|
this.loadedRequests[xhrId] = true;
|
||||||
|
|
||||||
var chunk = getArrayBuffer(xhr);
|
var chunk = getArrayBuffer(xhr);
|
||||||
if (xhr.status === PARTIAL_CONTENT_RESPONSE) {
|
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
|
||||||
var rangeHeader = xhr.getResponseHeader('Content-Range');
|
var rangeHeader = xhr.getResponseHeader('Content-Range');
|
||||||
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
|
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
|
||||||
var begin = parseInt(matches[1], 10);
|
var begin = parseInt(matches[1], 10);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user