Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions Polyfills/XMLHttpRequest/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,35 @@ Unlike the web, XMLHttpRequest supports loading local files using two schemes:
## Other things to be aware of:
* Only `GET` requests are currently supported
* For `readyState`, we only support `UNSENT`, `OPENED`, and `DONE`
* If the platform transport rejects a URL during `open()`, the request still
enters `OPENED`. Calling `send()` reports `DONE`, `error`, and `loadend`
asynchronously, with `status === 0`. This lets asset loaders handle unsupported
or scheme-less Native URLs through their error callbacks rather than aborting
scene parsing. No document-relative URL resolution is added.
* A URL that cannot be parsed (for example `//`, `http://`, or an invalid port)
throws a `SyntaxError` from `open()`, as in the XHR specification. Parsing is
checked as if the URL were resolved against a placeholder `http` base, so
scheme-less references such as `model.glb` are not malformed; the string
is still passed to the transport unchanged.
* Invalid methods, methods the platform transport does not support (for
example `POST` on Linux), invalid arguments, and unsupported request-body types
still throw synchronously. A deferred URL-open failure exposes `errorCode === "UrlOpenFailed"`
and the original error in `errorDetail`; reopening clears those diagnostics.
Aborting its pending notification returns `readyState` to `UNSENT` without
dispatching failure events; a new `open()` is required before another `send()`.

## Transport-error diagnostics (non-standard)
A transport-level failure surfaces the standard way -- an `error` event followed by `loadend`,
with `status === 0` -- exactly as on the web. In addition, two **non-standard, additive**
read-only properties expose the normalized `UrlLib` transport-error detail so BN-aware code can
tell a DNS failure from a refused connection or a missing local asset:
* `errorCode` -- the stable symbolic token (e.g. `"CURLE_COULDNT_CONNECT"`, `"NSURLErrorTimedOut"`,
* `errorCode` -- the stable symbolic token (e.g. `"UrlOpenFailed"`, `"CURLE_COULDNT_CONNECT"`, `"NSURLErrorTimedOut"`,
`"AppResourceNotFound"`)
* `errorDetail` -- the full normalized `"<domain>:<symbol>(<code>): <detail>"` string
* `errorDetail` -- the original opening error for `UrlOpenFailed`, or the normalized
`"<domain>:<symbol>(<code>): <detail>"` string for a failure during `send()`

Both are empty strings unless the request failed at the transport layer, and are populated only
on backends that expose the detail (Apple, Linux) -- empty on Windows/Android until those
backends populate `UrlLib`'s accessors. Browsers do not expose these properties, so
spec-conformant code is unaffected.
URL-opening errors populate both properties on every platform. Failures during
`send()` expose the diagnostics supplied by the platform's `UrlLib` backend;
those strings can be empty when the backend has no detail. Successful requests
leave both properties empty, and reopening clears an earlier opening error.
Browsers do not expose these properties, so spec-conformant code is unaffected.
Loading
Loading