Skip to content

Commit

Permalink
fix: fixed http2 issue for older versions of node (closes #1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Mar 28, 2019
1 parent f7e2ae5 commit 5b86fd3
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .lib.eslintrc
Expand Up @@ -4,7 +4,8 @@
"node/no-deprecated-api": "off",
"no-console": "off",
"no-unused-vars": "off",
"no-empty": "off"
"no-empty": "off",
"node/no-unsupported-features/node-builtins": "off"
},
"overrides": [
{
Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -83,8 +83,7 @@ Browser-ready versions of this module are available via [jsdelivr][], [unpkg][],
This is the solution for you if you're just using `<script>` tags everywhere!

```html
<!-- https://github.com/Financial-Times/polyfill-service/issues/1944 -->
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CPromise%2CSymbol%2CObject.setPrototypeOf"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CPromise%2CSymbol%2CObject.setPrototypeOf%2CObject.getOwnPropertySymbols"></script>
<script src="https://cdn.jsdelivr.net/npm/superagent"></script>
<!-- if you wish to use unpkg.com instead: -->
<!-- <script src="https://unpkg.com/superagent"></script> -->
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -30,7 +30,8 @@
"methods": "^1.1.2",
"mime": "^2.4.0",
"qs": "^6.7.0",
"readable-stream": "^3.2.0"
"readable-stream": "^3.2.0",
"semver": "^6.0.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
Expand Down Expand Up @@ -72,7 +73,7 @@
"zuul": "^3.12.0"
},
"engines": {
"node": ">= 8.8.1"
"node": ">= 6.4.0"
},
"homepage": "https://github.com/visionmedia/superagent",
"husky": {
Expand Down
2 changes: 0 additions & 2 deletions src/node/agent.js
@@ -1,5 +1,3 @@
'use strict';

/**
* Module dependencies.
*/
Expand Down
9 changes: 6 additions & 3 deletions src/node/http2wrapper.js
@@ -1,12 +1,15 @@
'use strict';

const http2 = require('http2');
const Stream = require('stream');
const util = require('util');
const net = require('net');
const tls = require('tls');
// eslint-disable-next-line node/no-deprecated-api
const { parse } = require('url');
const semver = require('semver');

let http2;
if (semver.gte(process.version, 'v10.10.0')) http2 = require('http2');
else
throw new Error('superagent: this version of Node.js does not support http2');

const {
HTTP2_HEADER_PATH,
Expand Down
9 changes: 4 additions & 5 deletions src/node/index.js
@@ -1,5 +1,3 @@
'use strict';

/**
* Module dependencies.
*/
Expand All @@ -19,16 +17,17 @@ const FormData = require('form-data');
const formidable = require('formidable');
const debug = require('debug')('superagent');
const CookieJar = require('cookiejar');
const semver = require('semver');

const utils = require('../utils');
const pkg = require('../../package.json');
const RequestBase = require('../request-base');
const { unzip } = require('./unzip');
const Response = require('./response');

let http2;
try {
http2 = require('./http2wrapper');
} catch (_) {}

if (semver.gte(process.version, 'v10.10.0')) http2 = require('./http2wrapper');

function request(method, url) {
// callback
Expand Down
2 changes: 0 additions & 2 deletions src/node/response.js
@@ -1,5 +1,3 @@
'use strict';

/**
* Module dependencies.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/node/unzip.js
@@ -1,5 +1,3 @@
'use strict';

/**
* Module dependencies.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/request-base.js
Expand Up @@ -260,12 +260,10 @@ RequestBase.prototype.then = function(resolve, reject) {
});
}

// eslint-disable-next-line promise/prefer-await-to-then
return this._fullfilledPromise.then(resolve, reject);
};

RequestBase.prototype.catch = function(cb) {
// eslint-disable-next-line promise/prefer-await-to-then
return this.then(undefined, cb);
};

Expand Down
37 changes: 21 additions & 16 deletions yarn.lock
Expand Up @@ -1960,14 +1960,14 @@ camelcase@^5.0.0:
integrity sha512-IXFsBS2pC+X0j0N/GE7Dm7j3bsEBp+oTpb7F50dwEVX7rf3IgwO9XatnegTsDtniKCUtEJH4fSU6Asw7uoVLfQ==

caniuse-db@^1.0.30000951:
version "1.0.30000954"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000954.tgz#ab9b0000d92a055747f380701684b9c9d017fca4"
integrity sha512-Rwd/JRb1/7wXzSOS5AQHXp4RBWXeNNPZW/9Gmv1kfO14ayrssFOM+vbu/0CPkYOCSZK6QZGMlrzaXznGLPkBAA==
version "1.0.30000955"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000955.tgz#d638a170f94654d77eff7821ec33b51dcd1330b0"
integrity sha512-VNb239mObbXMw9fWhd31idGYBG1gNBQc/qjUWa+ldoeWnjAkoeTZOowTMnVwcCiaMjbC7DNYw8YFkfdFlWLJrA==

caniuse-lite@^1.0.30000951, caniuse-lite@^1.0.30000954:
version "1.0.30000954"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000954.tgz#227c2743e40f07c71e6683b6ca9491bfd5755b8e"
integrity sha512-Wopmc0eVSSG1d9/O4JTn0OmGhUfhEHNkHhoCjUrGSImvHI+2YQWkOI1RRNTUFNSHbSAD8J41jbdZrPP4r32cbQ==
version "1.0.30000955"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000955.tgz#360fdb9a1e41d6dd996130411334e44a39e4446d"
integrity sha512-6AwmIKgqCYfDWWadRkAuZSHMQP4Mmy96xAXEdRBlN/luQhlRYOKgwOlZ9plpCOsVbBuqbTmGqDK3JUM/nlr8CA==

capture-stack-trace@^1.0.0:
version "1.0.1"
Expand Down Expand Up @@ -3431,9 +3431,9 @@ eslint-plugin-unicorn@^7.0.0:
safe-regex "^2.0.1"

eslint-rule-docs@^1.1.5:
version "1.1.85"
resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.85.tgz#ba8a4629457da916b361576495670428c125984a"
integrity sha512-CrNaaB1aYymFbuyMkEDC2u/+p8T7UrIbi9u6ASTjoIYD6zLhPXHttYAwjS+8D+1FDMXjf03ByT04MUMlqUDKng==
version "1.1.86"
resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.86.tgz#e3420659a19d48f137cecd04fc1f5f0957b54e22"
integrity sha512-9H+Yv0UlEeNPjKPBge1G1x366GY1SbRQZNxwkYh89MaCgciNwJAk62XoaE9DvaY4DPZ1uN5Z7z5k8UsINwcPJg==

eslint-scope@^4.0.3:
version "4.0.3"
Expand Down Expand Up @@ -3496,9 +3496,9 @@ eslint@^5.12.0, eslint@^5.15.3:
text-table "^0.2.0"

esm@^3.0.82:
version "3.2.20"
resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.20.tgz#44f125117863427cdece7223baa411fc739c1939"
integrity sha512-NA92qDA8C/qGX/xMinDGa3+cSPs4wQoFxskRrSnDo/9UloifhONFm4sl4G+JsyCqM007z2K+BfQlH5rMta4K1Q==
version "3.2.21"
resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.21.tgz#9cf6f1d7c70e22a641534f88ac01d6a1de5ba0a5"
integrity sha512-DkNi6jYtrT/FdO8pPEH+GFtBE321T3nup8FWdgaYpzaf4tK6aVJiCfgxNotZjEbnZ32t2VEtqIfbjp5GBN65Nw==

espree@^4.0.0:
version "4.1.0"
Expand Down Expand Up @@ -7203,9 +7203,9 @@ pako@~1.0.5:
integrity sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==

parent-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.0.tgz#df250bdc5391f4a085fb589dad761f5ad6b865b5"
integrity sha512-8Mf5juOMmiE4FcmzYc4IaiS9L3+9paz2KOiXzkRviCP6aDmN49Hz6EMWz0lGNp9pX80GvvAuLADtyGfW/Em3TA==
version "1.0.1"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==
dependencies:
callsites "^3.0.0"

Expand Down Expand Up @@ -8014,7 +8014,7 @@ remark-heading-gap@^3.0.0:
resolved "https://registry.yarnpkg.com/remark-heading-gap/-/remark-heading-gap-3.1.0.tgz#6a1851b4226fa82441ae1365bbd599d34b12d812"
integrity sha512-KxH9CTgfDnVTZVMMLJRw73zxZSWGX+p6x/trG7ed2UsEYqMRr8Dqtu/SXp2vD1ZZhPM8CpS7SjS+qjmiaRFotw==

remark-license@niftylettuce/remark-license:
"remark-license@github:niftylettuce/remark-license":
version "4.0.1"
resolved "https://codeload.github.com/niftylettuce/remark-license/tar.gz/17ecb8f64f8f6082414d14f9267a12764e6ddbfb"
dependencies:
Expand Down Expand Up @@ -9006,6 +9006,11 @@ semver@5.6.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==

semver@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65"
integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==

send@0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/send/-/send-0.1.4.tgz#be70d8d1be01de61821af13780b50345a4f71abd"
Expand Down

0 comments on commit 5b86fd3

Please sign in to comment.