A Node.js implementation of the WHATWG XMLHttpRequest Living Standard for non-browser environments. The XMLHttpRequest Standard defines an API that provides scripted client functionality for transferring data between a client and a server.
- WHATWG XMLHttpRequest Living Standard.
- web-platform-tests.
- Mozilla MDN XMLHttpRequest.
- The Modern JavaScript Tutorial - XMLHttpRequest.
npm install [-g] @essamonline/whatwg-xhr
With CommonJS in JavaScript,
const { XMLHttpRequest } = require('@essamonline/whatwg-xhr');
With ESM or TypeScript,
import { XMLHttpRequest } from '@essamonline/whatwg-xhr';
A command line testing utility wpt-xhr was developed and included as an executable script for the user to run and test the software on his local system. The compliance of the developed XMLHttpRequest implementation with WHATWG XMLHttpRequest Living Standard was tested using the live web-platform-tests server, where the wpt-xhr utility is configured to use by default.
The web-platform-tests allows the local installation of the wpt server, for the user to run the tests from his local system, with no need for an internet connection, and in such case the locally installed wpt server MUST be up and running, and its host and port information are given to the wpt-xhr as command line arguments before starting the tests.
Usage: wpt-xhr [OPTIONS]... [URL]
Test the developed *XMLHttpRequest* module for compliance with
WHATWG XMLHttpRequest specs using the web-platform-tests live
or locally installed server as the testing server.
With no URL, testing server is determined by the options given.
-t, --host[=<host>] wpt host (default wpt.live)
-p, --port[=<port>] wpt port (default 80)
--path[=<path>] wpt path (default /xhr/resources/)
-n --node use nodejs test runner API if supported
-d --def use default test runner
-v --verbose make the testing operation more talkative
-h --help display this help and exit
--version output version information and exit
Note that invalid host, port or path will not be accepted.
Examples:
wpt-xhr -t wpt.local -p 8000 Means <http://wpt.local:8000/xhr/resources/>
wpt-xhr Means <http://wpt.live/xhr/resources/>
web-platforms-tests online help: <https://web-platform-tests.org/>
Full documentation <https://essamatefelsherif.github.io/whatwg-xhr/>
- Supports http(s) and "data" URL schemes.
- Supports FormData, Blobs and Files.
- Supports synchronous and asynchronous operations.
- Independent of any existing implementation of fetch.
- No current support for "file" URL scheme, CORS or web streams.
Source code documentation, along with a test coverage report are both included under Documentation.
whatwg-xhr supports all currently maintained Node versions >= 15.4.0. See the Node Release Schedule.
This software is licensed under the MIT license, see the LICENSE file.