Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2

Open
wants to merge 47 commits into
base: add/ssl-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
df2aa18
Tests are running now.
mjwwit May 27, 2015
494938e
Switched to correct version.
mjwwit May 27, 2015
6e467d5
Pass the TLS options to redirected requests correctly.
sjakthol Aug 14, 2015
645c315
Merge pull request #1 from sjakthol/fix-tlsoptions-after-redirect
mjwwit Aug 15, 2015
f1f9298
Turn on strict mode
pskucherov Jan 16, 2016
0d9c921
Merge pull request #2 from pskucherov/use-strict
mjwwit Jan 26, 2016
9eb7a1b
Added npm test script. Bumped version.
Jan 26, 2016
83655a5
Use response.setEncoding() only if the function exists in response
Sep 20, 2016
f5a7014
Merge pull request #3 from jussikinnula/master
mjwwit Sep 20, 2016
d35e161
bumps version to 1.5.3
mjwwit Sep 20, 2016
ebc0076
Fix critical issues
david-clover-com Sep 25, 2017
d3533f7
Merge pull request #4 from david-clover-com/critical-fixes
mjwwit Sep 26, 2017
b0fa1e0
Prepare release 1.5.4
Sep 26, 2017
cefa6fa
ops can be null, there are places in the code that check for a null o…
david-clover-com Jan 5, 2018
6774da1
Merge pull request #5 from david-clover-com/handle-null-opts
mjwwit Jan 5, 2018
d0290fa
Prepare release 1.5.5
Jan 11, 2018
9d32e4f
Fixed abort/error/loadend event firing; statusCode is now 0 when all …
Jul 17, 2019
b9fedb0
pushed version to 1.5.6
Jul 17, 2019
efc39e9
Merge pull request #6 from wesgarland/master
mjwwit Jul 31, 2019
a9d93fb
Replace deprecated sys.puts calls with console.log in tests
mjwwit Jul 31, 2019
534b586
Remove superfluous + operator
mjwwit Jul 31, 2019
ae38832
1.6.0
mjwwit Jul 31, 2019
bf53329
Fix issue where rejectUnauthorized would default to false instead of …
mjwwit Apr 19, 2021
6a0a91d
Unescape pathname from url when loading from local filesystem
Apr 2, 2016
ee1e81f
Fix CVE-2020-28502
mjwwit May 4, 2021
4e8322f
Merge pull request #8 from mrcarlberg/mjwwit_unescape_url_pathname_wh…
mjwwit May 4, 2021
711bd4a
Prepare release 1.6.3
mjwwit May 17, 2021
fd05315
Add support for autoUnref.
shaoster May 21, 2021
fbe7c07
Expose error in status property when loading from local file system
mrcarlberg May 27, 2021
a8c2683
Merge pull request #9 from shaoster/feature/auto-unref
mjwwit Jun 1, 2021
baf1238
Merge pull request #10 from mrcarlberg/expose_error_in_status_propert…
mjwwit Jun 1, 2021
cbd48f1
Prepare release 2.0.0
mjwwit Jun 17, 2021
8514b4e
fix: proper fetching of binary data during get requests (#11)
RobertMirandola Oct 12, 2022
ab90421
Fix sync response handling of remote requests
mjwwit Oct 12, 2022
cf57429
Prevent corruption of UTF-8 multibyte codepoints at fragment boundary…
eroosenmaallen Jul 16, 2023
b01f69a
Replace setImmediate with setTimeout 0 (#14)
ericwooley Jul 16, 2023
39efe36
Prepare release 2.1.1
mjwwit Jul 16, 2023
b0271d5
Add GitHub action workflow config containing integration-tests (#15)
mjwwit Jul 17, 2023
3651620
Case-insensitive check for content type before setting it (#18)
YarnSaw Oct 23, 2024
7be2aa6
Handle ECONNRESET possible on reused sockets (#19)
YarnSaw Oct 23, 2024
acd5f61
destroy agent after completing keepalive test and replace some const/…
mjwwit Oct 23, 2024
bfa05a4
bump version to 2.1.2
mjwwit Oct 23, 2024
6d64b64
limit package files to main, license, and readme
mjwwit Oct 23, 2024
70949f7
Full implementation of xhr.responseType, rigorous test and a perf imp…
pringseth Nov 14, 2024
cfd991f
bump version to 3.0.0 and set minimum Node.js version to 12
mjwwit Nov 14, 2024
c5f1fc3
Data URI support, redirect checks and more (#26)
Bhpsngum Dec 7, 2024
76de70f
fix: use maxRedirects instead of max_redirects, failing tests now res…
mjwwit Dec 8, 2024
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
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.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
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
# 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 ###

Non-standard options for this module are passed through the `XMLHttpRequest` constructor. The following options control `https:` SSL requests: `ca`, `cert`, `ciphers`, `key`, `passphrase`, `pfx`, and `rejectUnauthorized`. You can find their functionality in the [Node.js docs](https://nodejs.org/api/https.html#httpsrequestoptions-callback).

Additionally, the `agent` option allows you to specify a [Node.js Agent](https://nodejs.org/api/https.html#class-httpsagent) instance, allowing connection reuse.

To prevent a process from not exiting naturally because a request socket from this module is still open, you can set `autoUnref` to a truthy value.

This module allows control over the maximum number of redirects that are followed. You can set the `maxRedirects` option to do this. The default number is 20.

Using the `allowFileSystemResources` option allows you to control access to the local filesystem through the `file:` protocol.

The `origin` option allows you to set a base URL for the request. The resulting request URL will be constructed as follows `new URL(url, origin)`.

# Original README #

## Versions ##

Version 2.0.0 introduces a potentially breaking change concerning local file system requests.
If these requests fail this library now returns the `errno` (or -1) as the response status code instead of
returning status code 0.

Prior to 1.4.0 version numbers were arbitrary. From 1.4.0 on they conform to
the standard major.minor.bugfix. 1.x shouldn't necessarily be considered
stable just because it's above 0.x.
Expand Down
8 changes: 4 additions & 4 deletions example/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function() {
sys.puts("State: " + this.readyState);
console.log("State: " + this.readyState);

if (this.readyState == 4) {
sys.puts("Complete.\nBody length: " + this.responseText.length);
sys.puts("Body:\n" + this.responseText);
console.log("Complete.\nBody length: " + this.responseText.length);
console.log("Body:\n" + this.responseText);
}
};

Expand Down
Loading