diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..541b904 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: +jobs: + integration-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [13.x, 20.x, 22.x, 23.x] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm test diff --git a/README.md b/README.md index b989434..0b5babb 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,115 @@ # node-XMLHttpRequest # -node-XMLHttpRequest is a wrapper for the built-in http client to emulate the -browser XMLHttpRequest object. +Fork of [node-XMLHttpRequest](https://github.com/driverdan/node-XMLHttpRequest) by [driverdan](http://driverdan.com). Forked and published to npm because a [pull request](https://github.com/rase-/node-XMLHttpRequest/commit/a6b6f296e0a8278165c2d0270d9840b54d5eeadd) is not being created and merged. Changes made by [rase-](https://github.com/rase-/node-XMLHttpRequest/tree/add/ssl-support) are needed for [engine.io-client](https://github.com/Automattic/engine.io-client). -This can be used with JS designed for browsers to improve reuse of code and -allow the use of existing libraries. - -Note: This library currently conforms to [XMLHttpRequest 1](http://www.w3.org/TR/XMLHttpRequest/). Version 2.0 will target [XMLHttpRequest Level 2](http://www.w3.org/TR/XMLHttpRequest2/). - -## Usage ## +## Usage ## Here's how to include the module in your project and use as the browser-based XHR object. - var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; + var XMLHttpRequest = require("xmlhttprequest-ssl").XMLHttpRequest; var xhr = new XMLHttpRequest(); -Note: use the lowercase string "xmlhttprequest" in your require(). On +Note: use the lowercase string "xmlhttprequest-ssl" in your require(). On case-sensitive systems (eg Linux) using uppercase letters won't work. +## Non-standard features ## +### Additional options ### + +Non-standard options for this module are passed through the `XMLHttpRequest` constructor. Here is the list of all options: + +
| Option | +Default value | +Description | +
|---|---|---|
ca |
+ undefined |
+ Control https: requests, you can find their functionality in the Nodejs Documentation |
+
cert |
+ ||
ciphers |
+ ||
key |
+ ||
passhphrase |
+ ||
pfx |
+ ||
rejectUnauthorized |
+ true |
+ |
agent |
+ undefined |
+ Allows to specify a Nodejs Agent instance, allowing connection reuse | +
autoUnref |
+ false |
+ Set to any truthy value to prevent a process from not exiting naturally because a request socket from this module is still open | +
maxRedirects |
+ 20 |
+ Allows control over the maximum number of redirects that are followed | +
allowFileSystemResources |
+ true |
+ Allows control access to the local filesystem through the file: protocol |
+
origin |
+ undefined |
+ Set a base URL for the requests called using this instance. The resulting request URL will be constructed as follows: new URL(url, origin) |
+
syncPolicy |
+ "warn" |
+ Control feature behavior of the synchronous feature:
|
+
disableHeaderCheck |
+ false |
+ Disable the check against forbidden headers to be added to a XHR request | +
xmlParser |
+ none | +Specify a parser (non-async) to parse document from text when xhr.responseType is either "document" or in text format. If the parser is invalid or omitted, xhr.responseXML will be null |
+
textDecoder |
+ TextDecoder or buf.toString(enc) depending on Node version |
+ Specify a text decoder (non-async), accepting a buffer buf and encoding enc to decode to desired encoding.Note that TextDecoder at version 12 does not support a wide range of encodings than later node version does |
+