XMLHttpRequest has from the beginning been defined as usable in either sync or async mode
The editor draft of the new edition (level 2) of the specification now forbid the async mode in the "document environment" (the main UI thread) where it would block user interaction It is then more explicit that synchronous APIs are not bad as long as they are not running in the main UI thread (and then ok for worker and multi-threaded contexts)
It also specify that if in a "worker environment", the response body is not exposed as a DOM Object in the response property which is then set to null
- The document response entity body is either a document representing the response entity body or null. If the document response entity body has no value assigned to it let it be the return value of the following algorithm:
Setting the responseType attribute to "document" is cancelled in a "worker environment"
- '4.7.7 The responseType attribute'
- Setting the responseType attribute must run these steps:
The responseXML attribute is then meant, in worker environment, at best to return null (value set in the internal “document response entity body"), or, if responseType is not empty string (as previously said it can not be set to "document"), it will throw an "InvalidState" error
- The responseXML attribute must return the result of running these steps:
- 1. If responseType is not the empty string or "document", throw an "InvalidStateError" exception and terminate these steps.
- 4. Return the document response entity body.
We are looking for representatives of this HTML5 API to discuss of potentially needed updates to consider server-side implementations
- Server-Side API should not have Cross Origin Resource Sharing constraints. It may simulate this part of the API to remain compatible with client-side code
- Some forbidden HTTP header access might be allowed on server side
- XML not being mandatory any more an alias "HTTPRequest" might be defined for the XMLHttpRequest constructor
- At the moment, this mostly follows the v1 spec.
- Does not support XML/HTML parsing
- Does not support Events (from V2 spec)
- This is SYNCHRONOUS, as async requires a reactor
An implementation is available:
XMLHttpRequest is partially implemented:
Third party module
Node.js provide a different API called http.request:
A third party module with the W3C API exists: node-xmlhttprequest