mirror of
https://github.com/matrix-construct/construct
synced 2024-05-29 08:13:46 +02:00
client: Case and fixes for non-http (file://) to io.request.
This commit is contained in:
parent
529bef7321
commit
abf0ff294b
|
@ -427,9 +427,15 @@ mc.io.request.on.readystatechange[XMLHttpRequest.LOADING] = function(event)
|
||||||
|
|
||||||
mc.io.request.on.readystatechange[XMLHttpRequest.DONE] = function(event)
|
mc.io.request.on.readystatechange[XMLHttpRequest.DONE] = function(event)
|
||||||
{
|
{
|
||||||
mc.io.request.destructor.call(this);
|
|
||||||
|
|
||||||
let code = parseInt(this.xhr.status);
|
let code = parseInt(this.xhr.status);
|
||||||
|
|
||||||
|
// Case for file:// protocol which reports code 0 (since it's not HTTP)
|
||||||
|
// on success and failure; we test for success here and manually assign
|
||||||
|
// a 200 code.
|
||||||
|
if(!code && this.xhr.responseURL.startsWith("file://"))
|
||||||
|
code = defined(this.xhr.response)? 200 : 0;
|
||||||
|
|
||||||
|
mc.io.request.destructor.call(this);
|
||||||
switch(Math.floor(code / 100))
|
switch(Math.floor(code / 100))
|
||||||
{
|
{
|
||||||
case 2: // 2xx
|
case 2: // 2xx
|
||||||
|
@ -504,6 +510,8 @@ mc.io.request.error = function(event)
|
||||||
undefined,
|
undefined,
|
||||||
|
|
||||||
name:
|
name:
|
||||||
|
empty(this.xhr)?
|
||||||
|
"Network Request Not Possible":
|
||||||
this.xhr.statusText == "error"?
|
this.xhr.statusText == "error"?
|
||||||
"Network Request Error":
|
"Network Request Error":
|
||||||
this.xhr.statusText == "abort"?
|
this.xhr.statusText == "abort"?
|
||||||
|
@ -516,9 +524,9 @@ mc.io.request.error = function(event)
|
||||||
this.reason:
|
this.reason:
|
||||||
!window.navigator.onLine?
|
!window.navigator.onLine?
|
||||||
"disconnected":
|
"disconnected":
|
||||||
this.started + 10 > mc.now()?
|
this.started + (10 * 1000) < mc.now()?
|
||||||
"killed":
|
"timeout":
|
||||||
"timeout",
|
"unknown/unhandled",
|
||||||
|
|
||||||
status:
|
status:
|
||||||
this.xhr.status != 0? this.xhr.status : "Client",
|
this.xhr.status != 0? this.xhr.status : "Client",
|
||||||
|
|
Loading…
Reference in a new issue