urllib 3.17.1 → 3.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/HttpAgent.ts +6 -3
- package/src/HttpClient.ts +5 -0
- package/src/cjs/HttpAgent.js +4 -1
- package/src/cjs/HttpClient.js +6 -1
- package/src/esm/HttpAgent.js +4 -1
- package/src/esm/HttpClient.js +6 -1
package/package.json
CHANGED
package/src/HttpAgent.ts
CHANGED
@@ -37,8 +37,11 @@ export class HttpAgent extends Agent {
|
|
37
37
|
/* eslint node/prefer-promises/dns: off*/
|
38
38
|
const _lookup = options.lookup ?? dns.lookup;
|
39
39
|
const lookup: LookupFunction = (hostname, dnsOptions, callback) => {
|
40
|
-
_lookup(hostname, dnsOptions, (err,
|
41
|
-
|
40
|
+
_lookup(hostname, dnsOptions, (err, ...args: any[]) => {
|
41
|
+
// address will be array on Node.js >= 20
|
42
|
+
const address = args[0];
|
43
|
+
const family = args[1];
|
44
|
+
if (err) return (callback as any)(err, address, family);
|
42
45
|
if (options.checkAddress) {
|
43
46
|
// dnsOptions.all set to default on Node.js >= 20, dns.lookup will return address array object
|
44
47
|
if (typeof address === 'string') {
|
@@ -55,7 +58,7 @@ export class HttpAgent extends Agent {
|
|
55
58
|
}
|
56
59
|
}
|
57
60
|
}
|
58
|
-
callback(err, address, family);
|
61
|
+
(callback as any)(err, address, family);
|
59
62
|
});
|
60
63
|
};
|
61
64
|
super({
|
package/src/HttpClient.ts
CHANGED
@@ -58,6 +58,8 @@ function noop() {
|
|
58
58
|
}
|
59
59
|
|
60
60
|
const debug = debuglog('urllib:HttpClient');
|
61
|
+
// Node.js 14 or 16
|
62
|
+
const isNode14Or16 = /v1[46]\./.test(process.version);
|
61
63
|
|
62
64
|
export type ClientOptions = {
|
63
65
|
defaultArgs?: RequestOptions;
|
@@ -543,6 +545,9 @@ export class HttpClient extends EventEmitter {
|
|
543
545
|
res = Object.assign(response.body, res);
|
544
546
|
}
|
545
547
|
} else if (args.writeStream) {
|
548
|
+
if (isNode14Or16 && args.writeStream.destroyed) {
|
549
|
+
throw new Error('writeStream is destroyed');
|
550
|
+
}
|
546
551
|
if (args.compressed === true && isCompressedContent) {
|
547
552
|
const decoder = contentEncoding === 'gzip' ? createGunzip() : createBrotliDecompress();
|
548
553
|
await pipelinePromise(response.body, decoder, args.writeStream);
|
package/src/cjs/HttpAgent.js
CHANGED
@@ -27,7 +27,10 @@ class HttpAgent extends undici_1.Agent {
|
|
27
27
|
/* eslint node/prefer-promises/dns: off*/
|
28
28
|
const _lookup = options.lookup ?? node_dns_1.default.lookup;
|
29
29
|
const lookup = (hostname, dnsOptions, callback) => {
|
30
|
-
_lookup(hostname, dnsOptions, (err,
|
30
|
+
_lookup(hostname, dnsOptions, (err, ...args) => {
|
31
|
+
// address will be array on Node.js >= 20
|
32
|
+
const address = args[0];
|
33
|
+
const family = args[1];
|
31
34
|
if (err)
|
32
35
|
return callback(err, address, family);
|
33
36
|
if (options.checkAddress) {
|
package/src/cjs/HttpClient.js
CHANGED
@@ -44,6 +44,8 @@ function noop() {
|
|
44
44
|
// noop
|
45
45
|
}
|
46
46
|
const debug = (0, node_util_1.debuglog)('urllib:HttpClient');
|
47
|
+
// Node.js 14 or 16
|
48
|
+
const isNode14Or16 = /v1[46]\./.test(process.version);
|
47
49
|
// https://github.com/octet-stream/form-data
|
48
50
|
class BlobFromStream {
|
49
51
|
#stream;
|
@@ -70,7 +72,7 @@ class HttpClientRequestTimeoutError extends Error {
|
|
70
72
|
Error.captureStackTrace(this, this.constructor);
|
71
73
|
}
|
72
74
|
}
|
73
|
-
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.17.
|
75
|
+
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.17.2');
|
74
76
|
function getFileName(stream) {
|
75
77
|
const filePath = stream.path;
|
76
78
|
if (filePath) {
|
@@ -472,6 +474,9 @@ class HttpClient extends node_events_1.EventEmitter {
|
|
472
474
|
}
|
473
475
|
}
|
474
476
|
else if (args.writeStream) {
|
477
|
+
if (isNode14Or16 && args.writeStream.destroyed) {
|
478
|
+
throw new Error('writeStream is destroyed');
|
479
|
+
}
|
475
480
|
if (args.compressed === true && isCompressedContent) {
|
476
481
|
const decoder = contentEncoding === 'gzip' ? (0, node_zlib_1.createGunzip)() : (0, node_zlib_1.createBrotliDecompress)();
|
477
482
|
await pipelinePromise(response.body, decoder, args.writeStream);
|
package/src/esm/HttpAgent.js
CHANGED
@@ -21,7 +21,10 @@ export class HttpAgent extends Agent {
|
|
21
21
|
/* eslint node/prefer-promises/dns: off*/
|
22
22
|
const _lookup = options.lookup ?? dns.lookup;
|
23
23
|
const lookup = (hostname, dnsOptions, callback) => {
|
24
|
-
_lookup(hostname, dnsOptions, (err,
|
24
|
+
_lookup(hostname, dnsOptions, (err, ...args) => {
|
25
|
+
// address will be array on Node.js >= 20
|
26
|
+
const address = args[0];
|
27
|
+
const family = args[1];
|
25
28
|
if (err)
|
26
29
|
return callback(err, address, family);
|
27
30
|
if (options.checkAddress) {
|
package/src/esm/HttpClient.js
CHANGED
@@ -38,6 +38,8 @@ function noop() {
|
|
38
38
|
// noop
|
39
39
|
}
|
40
40
|
const debug = debuglog('urllib:HttpClient');
|
41
|
+
// Node.js 14 or 16
|
42
|
+
const isNode14Or16 = /v1[46]\./.test(process.version);
|
41
43
|
// https://github.com/octet-stream/form-data
|
42
44
|
class BlobFromStream {
|
43
45
|
#stream;
|
@@ -64,7 +66,7 @@ class HttpClientRequestTimeoutError extends Error {
|
|
64
66
|
Error.captureStackTrace(this, this.constructor);
|
65
67
|
}
|
66
68
|
}
|
67
|
-
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.17.
|
69
|
+
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.17.2');
|
68
70
|
function getFileName(stream) {
|
69
71
|
const filePath = stream.path;
|
70
72
|
if (filePath) {
|
@@ -466,6 +468,9 @@ export class HttpClient extends EventEmitter {
|
|
466
468
|
}
|
467
469
|
}
|
468
470
|
else if (args.writeStream) {
|
471
|
+
if (isNode14Or16 && args.writeStream.destroyed) {
|
472
|
+
throw new Error('writeStream is destroyed');
|
473
|
+
}
|
469
474
|
if (args.compressed === true && isCompressedContent) {
|
470
475
|
const decoder = contentEncoding === 'gzip' ? createGunzip() : createBrotliDecompress();
|
471
476
|
await pipelinePromise(response.body, decoder, args.writeStream);
|