Commit 9406dae authored Apr 26, 2024 · 7 / 7 · Verified
File tree 4 files changed +4
-41
lines changed
4 files changed +4
-41
lines changed Original file line number Diff line number Diff line change 6
6
"browser" : {
7
7
"./src/node/index.js" : " ./src/client.js" ,
8
8
"./lib/node/index.js" : " ./lib/client.js" ,
9
- "./test/support/server.js" : " ./test/support/blank.js" ,
10
- "semver" : false
9
+ "./test/support/server.js" : " ./test/support/blank.js"
11
10
},
12
11
"bugs" : {
13
12
"url" : " https://github.com/ladjs/superagent/issues"
27
26
"formidable" : " ^3.5.1" ,
28
27
"methods" : " ^1.1.2" ,
29
28
"mime" : " 2.6.0" ,
30
- "qs" : " ^6.11.0" ,
31
- "semver" : " ^7.3.8"
29
+ "qs" : " ^6.11.0"
32
30
},
33
31
"devDependencies" : {
34
32
"@babel/cli" : " ^7.20.7" ,
Original file line number Diff line number Diff line change
1
+ const http2 = require ( 'http2' ) ;
1
2
const Stream = require ( 'stream' ) ;
2
3
const net = require ( 'net' ) ;
3
4
const tls = require ( 'tls' ) ;
4
5
// eslint-disable-next-line node/no-deprecated-api
5
6
const { parse } = require ( 'url' ) ;
6
- const process = require ( 'process' ) ;
7
- const semverGte = require ( 'semver/functions/gte' ) ;
8
-
9
- let http2 ;
10
-
11
- if ( semverGte ( process . version , 'v10.10.0' ) ) http2 = require ( 'http2' ) ;
12
- else
13
- throw new Error ( 'superagent: this version of Node.js does not support http2' ) ;
14
7
15
8
const {
16
9
HTTP2_HEADER_PATH ,
Original file line number Diff line number Diff line change @@ -16,20 +16,16 @@ const FormData = require('form-data');
16
16
const formidable = require ( 'formidable' ) ;
17
17
const debug = require ( 'debug' ) ( 'superagent' ) ;
18
18
const CookieJar = require ( 'cookiejar' ) ;
19
- const semverGte = require ( 'semver/functions/gte' ) ;
20
19
const safeStringify = require ( 'fast-safe-stringify' ) ;
21
20
22
21
const utils = require ( '../utils' ) ;
23
22
const RequestBase = require ( '../request-base' ) ;
23
+ const http2 = require ( './http2wrapper' ) ;
24
24
const { unzip } = require ( './unzip' ) ;
25
25
const Response = require ( './response' ) ;
26
26
27
27
const { mixin, hasOwn } = utils ;
28
28
29
- let http2 ;
30
-
31
- if ( semverGte ( process . version , 'v10.10.0' ) ) http2 = require ( './http2wrapper' ) ;
32
-
33
29
function request ( method , url ) {
34
30
// callback
35
31
if ( typeof url === 'function' ) {
Original file line number Diff line number Diff line change 1
- const semver = require ( 'semver' ) ;
2
-
3
1
/**
4
2
* Module of mixed-in functions shared between node and client code
5
3
*/
@@ -481,28 +479,6 @@ RequestBase.prototype.abort = function () {
481
479
this . _aborted = true ;
482
480
if ( this . xhr ) this . xhr . abort ( ) ; // browser
483
481
if ( this . req ) {
484
- // Node v13 has major differences in `abort()`
485
- // https://github.com/nodejs/node/blob/v12.x/lib/internal/streams/end-of-stream.js
486
- // https://github.com/nodejs/node/blob/v13.x/lib/internal/streams/end-of-stream.js
487
- // https://github.com/nodejs/node/blob/v14.x/lib/internal/streams/end-of-stream.js
488
- // (if you run a diff across these you will see the differences)
489
- //
490
- // References:
491
- // <https://github.com/nodejs/node/issues/31630>
492
- // <https://github.com/ladjs/superagent/pull/1084/commits/dc18679a7c5ccfc6046d882015e5126888973bc8>
493
- //
494
- // Thanks to @shadowgate 15 and @niftylettuce
495
- if (
496
- semver . gte ( process . version , 'v13.0.0' ) &&
497
- semver . lt ( process . version , 'v14.0.0' )
498
- ) {
499
- // Note that the reason this doesn't work is because in v13 as compared to v14
500
- // there is no `callback = nop` set in end-of-stream.js above
501
- throw new Error (
502
- 'Superagent does not work in v13 properly with abort() due to Node.js core changes'
503
- ) ;
504
- }
505
-
506
482
this . req . abort ( ) ; // node
507
483
}
508
484
You can’t perform that action at this time.
0 commit comments