Merge pull request #3294 from yurydelendik/status0
Allows status be 0 for non-HTTP protocols
This commit is contained in:
commit
30d55d9c14
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user