Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eladio Mora committed Jan 7, 2020
2 parents fee770a + 64b4dac commit 2d8e7dc
Show file tree
Hide file tree
Showing 34 changed files with 3,199 additions and 2,618 deletions.
3 changes: 2 additions & 1 deletion .dist.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"browsers": [ "> 1%", "last 2 versions", "ie 9" ]
}
}]
]
],
"sourceMaps": "inline"
}
3 changes: 2 additions & 1 deletion .dist.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"no-unused-vars": "off",
"no-useless-escape": "off",
"no-cond-assign": "off",
"no-redeclare": "off"
"no-redeclare": "off",
"node/no-exports-assign": "off"
},
"globals": {
"regeneratorRuntime": "writable"
Expand Down
3 changes: 2 additions & 1 deletion .lib.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"browsers": [ "> 1%", "last 2 versions", "ie 9" ]
}
}]
]
],
"sourceMaps": "inline"
}
3 changes: 2 additions & 1 deletion .lib.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"no-empty": "off",
"node/no-unsupported-features/node-builtins": "off",
"no-func-assign": "off",
"no-global-assign": ["error", {"exceptions": ["exports"]}]
"no-global-assign": ["error", {"exceptions": ["exports"]}],
"node/no-exports-assign": "off"
},
"overrides": [
{
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test-node:
@NODE_ENV=test ./node_modules/.bin/mocha \
--require should \
--trace-warnings \
--throw-deprecation \
--reporter $(REPORTER) \
--timeout 5000 \
$(NODETESTS)
Expand All @@ -18,6 +19,7 @@ test-node-http2:
@NODE_ENV=test HTTP2_TEST=1 node ./node_modules/.bin/mocha \
--require should \
--trace-warnings \
--throw-deprecation \
--reporter $(REPORTER) \
--timeout 5000 \
$(NODETESTS)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Existing plugins:
* [superagent-charset](https://github.com/magicdawn/superagent-charset) - add charset support for node's SuperAgent
* [superagent-verbose-errors](https://github.com/jcoreio/superagent-verbose-errors) - include response body in error messages for failed requests
* [superagent-declare](https://github.com/damoclark/superagent-declare) - A simple [declarative](https://en.wikipedia.org/wiki/Declarative_programming) API for SuperAgent
* [superagent-node-http-timings](https://github.com/webuniverseio/superagent-node-http-timings) - measure http timings in node.js
Please prefix your plugin with `superagent-*` so that it can easily be found by others.
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ In Node.js SuperAgent supports methods to configure HTTPS requests:
- `.cert()`: Set the client certificate chain(s)
- `.key()`: Set the client private key(s)
- `.pfx()`: Set the client PFX or PKCS12 encoded private key and certificate chain
- `.disableTLSCerts()`: Does not reject expired or invalid TLS certs. Sets internally `rejectUnauthorized=true`. *Be warned, this method allows MITM attacks.*

For more information, see Node.js [https.request docs](https://nodejs.org/api/https.html#https_https_request_options_callback).

Expand Down
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "superagent",
"description": "elegant & feature rich browser / node HTTP with a fluent API",
"version": "5.1.0",
"version": "5.2.1",
"author": "TJ Holowaychuk <[email protected]>",
"browser": {
"./src/node/index.js": "./src/client.js",
Expand All @@ -26,50 +26,50 @@
"component-emitter": "^1.3.0",
"cookiejar": "^2.1.2",
"debug": "^4.1.1",
"fast-safe-stringify": "^2.0.6",
"form-data": "^2.3.3",
"fast-safe-stringify": "^2.0.7",
"form-data": "^3.0.0",
"formidable": "^1.2.1",
"methods": "^1.1.2",
"mime": "^2.4.4",
"qs": "^6.7.0",
"qs": "^6.9.1",
"readable-stream": "^3.4.0",
"semver": "^6.1.1"
"semver": "^6.3.0"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"Base64": "^1.0.2",
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"Base64": "^1.1.0",
"babelify": "^10.0.0",
"basic-auth-connect": "^1.0.0",
"body-parser": "^1.19.0",
"browserify": "^16.2.3",
"codecov": "^3.5.0",
"browserify": "^16.5.0",
"codecov": "^3.6.1",
"cookie-parser": "^1.4.4",
"cross-env": "^5.2.0",
"eslint": "^5.16.0",
"cross-env": "^6.0.3",
"eslint": "^6.7.2",
"eslint-config-xo-lass": "^1.0.3",
"eslint-plugin-compat": "^3.1.1",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-compat": "^3.3.0",
"eslint-plugin-node": "^10.0.0",
"express": "^4.17.1",
"express-session": "^1.16.2",
"express-session": "^1.17.0",
"fixpack": "^2.3.1",
"husky": "^2.4.1",
"lint-staged": "^8.2.0",
"marked": "^0.6.2",
"husky": "^3.1.0",
"lint-staged": "^9.5.0",
"marked": "^0.7.0",
"mocha": "3.5.3",
"multer": "^1.4.1",
"multer": "^1.4.2",
"nyc": "^14.1.1",
"remark-cli": "^6.0.1",
"remark-preset-github": "^0.0.13",
"rimraf": "^2.6.3",
"remark-cli": "^7.0.1",
"remark-preset-github": "^0.0.16",
"rimraf": "^3.0.0",
"should": "^13.2.3",
"should-http": "^0.1.1",
"tinyify": "^2.5.1",
"uglify-js": "^3.6.0",
"xo": "0.24.0",
"tinyify": "^2.5.2",
"uglify-js": "^3.7.1",
"xo": "0.25.3",
"zuul": "^3.12.0"
},
"engines": {
Expand Down
3 changes: 2 additions & 1 deletion src/agent-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function Agent() {
'ca',
'key',
'pfx',
'cert'
'cert',
'disableTLSCerts'
].forEach(fn => {
// Default setting for all requests from this agent
Agent.prototype[fn] = function(...args) {
Expand Down
26 changes: 14 additions & 12 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ request.getXHR = () => {

try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch (err) {}
} catch {}

try {
return new ActiveXObject('Msxml2.XMLHTTP.6.0');
} catch (err) {}
} catch {}

try {
return new ActiveXObject('Msxml2.XMLHTTP.3.0');
} catch (err) {}
} catch {}

try {
return new ActiveXObject('Msxml2.XMLHTTP');
} catch (err) {}
} catch {}

throw new Error('Browser-only version of superagent could not find XHR');
};
Expand Down Expand Up @@ -437,10 +437,10 @@ function Request(method, url) {

try {
res = new Response(self);
} catch (err2) {
} catch (err_) {
err = new Error('Parser is unable to parse the response');
err.parse = true;
err.original = err2;
err.original = err_;
// issue #675: return the raw response if the response parsing fails
if (self.xhr) {
// ie9 doesn't have 'response' property
Expand All @@ -464,10 +464,12 @@ function Request(method, url) {
let new_err;
try {
if (!self._isResponseOK(res)) {
new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
new_err = new Error(
res.statusText || res.text || 'Unsuccessful HTTP response'
);
}
} catch (err2) {
new_err = err2; // ok() callback can throw
} catch (err_) {
new_err = err_; // ok() callback can throw
}

// #1000 don't catch errors from the callback to avoid double calling it
Expand Down Expand Up @@ -685,8 +687,8 @@ Request.prototype.agent = function() {
return this;
};

Request.prototype.buffer = Request.prototype.ca;
Request.prototype.ca = Request.prototype.agent;
Request.prototype.buffer = Request.prototype.ca;

// This throws, because it can't send/receive data as expected
Request.prototype.write = () => {
Expand Down Expand Up @@ -787,7 +789,7 @@ Request.prototype._end = function() {
let status;
try {
status = xhr.status;
} catch (err) {
} catch {
status = 0;
}

Expand Down Expand Up @@ -822,7 +824,7 @@ Request.prototype._end = function() {
handleProgress.bind(null, 'upload')
);
}
} catch (err) {
} catch {
// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.
// Reported here:
// https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context
Expand Down
4 changes: 4 additions & 0 deletions src/node/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function Agent(options) {
this.cert(options.cert);
}

if (options.rejectUnauthorized === false) {
this.disableTLSCerts();
}

if (options.secureCookie) {
this.secureCookie(options.secureCookie);
}
Expand Down
11 changes: 3 additions & 8 deletions src/node/http2wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ Request.prototype.getFrame = function() {
Request.prototype.mapToHttpHeader = function(headers) {
const keys = Object.keys(headers);
const http2Headers = {};
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
for (let key of keys) {
let value = headers[key];
key = key.toLowerCase();
switch (key) {
Expand All @@ -147,8 +146,7 @@ Request.prototype.mapToHttpHeader = function(headers) {
Request.prototype.mapToHttp2Header = function(headers) {
const keys = Object.keys(headers);
const http2Headers = {};
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
for (let key of keys) {
let value = headers[key];
key = key.toLowerCase();
switch (key) {
Expand Down Expand Up @@ -183,10 +181,7 @@ Request.prototype.write = function(data, encoding) {

Request.prototype.pipe = function(stream, options) {
const frame = this.getFrame();
return frame.pipe(
stream,
options
);
return frame.pipe(stream, options);
};

Request.prototype.end = function(data) {
Expand Down
Loading

0 comments on commit 2d8e7dc

Please sign in to comment.