mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
client: Case and fixes for non-http (file://) to io.request.
This commit is contained in:
parent
529bef7321
commit
abf0ff294b
1 changed files with 13 additions and 5 deletions
|
@ -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.destructor.call(this);
|
||||
|
||||
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))
|
||||
{
|
||||
case 2: // 2xx
|
||||
|
@ -504,6 +510,8 @@ mc.io.request.error = function(event)
|
|||
undefined,
|
||||
|
||||
name:
|
||||
empty(this.xhr)?
|
||||
"Network Request Not Possible":
|
||||
this.xhr.statusText == "error"?
|
||||
"Network Request Error":
|
||||
this.xhr.statusText == "abort"?
|
||||
|
@ -516,9 +524,9 @@ mc.io.request.error = function(event)
|
|||
this.reason:
|
||||
!window.navigator.onLine?
|
||||
"disconnected":
|
||||
this.started + 10 > mc.now()?
|
||||
"killed":
|
||||
"timeout",
|
||||
this.started + (10 * 1000) < mc.now()?
|
||||
"timeout":
|
||||
"unknown/unhandled",
|
||||
|
||||
status:
|
||||
this.xhr.status != 0? this.xhr.status : "Client",
|
||||
|
|
Loading…
Reference in a new issue