urllib 3.27.2 → 3.27.3
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/dist/commonjs/HttpClient.d.ts +1 -1
- package/dist/commonjs/HttpClient.js +16 -3
- package/dist/esm/HttpClient.d.ts +1 -1
- package/dist/esm/HttpClient.js +17 -4
- package/dist/package.json +1 -1
- package/package.json +3 -3
- package/src/HttpClient.ts +18 -4
|
@@ -73,7 +73,7 @@ export declare class HttpClient extends EventEmitter {
|
|
|
73
73
|
#private;
|
|
74
74
|
constructor(clientOptions?: ClientOptions);
|
|
75
75
|
getDispatcher(): Dispatcher;
|
|
76
|
-
setDispatcher(dispatcher
|
|
76
|
+
setDispatcher(dispatcher?: Dispatcher): void;
|
|
77
77
|
getDispatcherPoolStats(): Record<string, PoolStat>;
|
|
78
78
|
request<T = any>(url: RequestURL, options?: RequestOptions): Promise<HttpClientResponse<T>>;
|
|
79
79
|
curl<T = any>(url: RequestURL, options?: RequestOptions): Promise<HttpClientResponse<T>>;
|
|
@@ -68,7 +68,7 @@ class BlobFromStream {
|
|
|
68
68
|
return 'Blob';
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.27.
|
|
71
|
+
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.27.3');
|
|
72
72
|
function getFileName(stream) {
|
|
73
73
|
const filePath = stream.path;
|
|
74
74
|
if (filePath) {
|
|
@@ -112,7 +112,20 @@ class HttpClient extends node_events_1.EventEmitter {
|
|
|
112
112
|
(0, diagnosticsChannel_js_1.initDiagnosticsChannel)();
|
|
113
113
|
}
|
|
114
114
|
getDispatcher() {
|
|
115
|
-
|
|
115
|
+
if (this.#dispatcher) {
|
|
116
|
+
return this.#dispatcher;
|
|
117
|
+
}
|
|
118
|
+
// In a multi-version undici environment
|
|
119
|
+
// the global dispatcher is the highest version of undici
|
|
120
|
+
// which will conflict with the maxRedirects field and report an error
|
|
121
|
+
// so we need to create it that use 5.x version
|
|
122
|
+
const globalDispatcher = (0, undici_1.getGlobalDispatcher)();
|
|
123
|
+
if (!(globalDispatcher instanceof undici_1.Agent) && !(globalDispatcher instanceof undici_1.MockAgent)) {
|
|
124
|
+
const dispatcher = globalDispatcher.constructor.name === 'MockAgent' ? new undici_1.MockAgent() : new undici_1.Agent();
|
|
125
|
+
this.setDispatcher(dispatcher);
|
|
126
|
+
return dispatcher;
|
|
127
|
+
}
|
|
128
|
+
return globalDispatcher;
|
|
116
129
|
}
|
|
117
130
|
setDispatcher(dispatcher) {
|
|
118
131
|
this.#dispatcher = dispatcher;
|
|
@@ -315,7 +328,7 @@ class HttpClient extends node_events_1.EventEmitter {
|
|
|
315
328
|
headers,
|
|
316
329
|
bodyTimeout,
|
|
317
330
|
opaque: internalOpaque,
|
|
318
|
-
dispatcher: args.dispatcher ?? this
|
|
331
|
+
dispatcher: args.dispatcher ?? this.getDispatcher(),
|
|
319
332
|
signal: args.signal,
|
|
320
333
|
};
|
|
321
334
|
if (typeof args.highWaterMark === 'number') {
|
package/dist/esm/HttpClient.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare class HttpClient extends EventEmitter {
|
|
|
73
73
|
#private;
|
|
74
74
|
constructor(clientOptions?: ClientOptions);
|
|
75
75
|
getDispatcher(): Dispatcher;
|
|
76
|
-
setDispatcher(dispatcher
|
|
76
|
+
setDispatcher(dispatcher?: Dispatcher): void;
|
|
77
77
|
getDispatcherPoolStats(): Record<string, PoolStat>;
|
|
78
78
|
request<T = any>(url: RequestURL, options?: RequestOptions): Promise<HttpClientResponse<T>>;
|
|
79
79
|
curl<T = any>(url: RequestURL, options?: RequestOptions): Promise<HttpClientResponse<T>>;
|
package/dist/esm/HttpClient.js
CHANGED
|
@@ -11,7 +11,7 @@ import { createReadStream } from 'node:fs';
|
|
|
11
11
|
import { format as urlFormat } from 'node:url';
|
|
12
12
|
import { performance } from 'node:perf_hooks';
|
|
13
13
|
import querystring from 'node:querystring';
|
|
14
|
-
import { FormData as FormDataNative, request as undiciRequest, Agent, getGlobalDispatcher, } from 'undici';
|
|
14
|
+
import { FormData as FormDataNative, request as undiciRequest, Agent, getGlobalDispatcher, MockAgent, } from 'undici';
|
|
15
15
|
import undiciSymbols from 'undici/lib/core/symbols.js';
|
|
16
16
|
import { FormData as FormDataNode } from 'formdata-node';
|
|
17
17
|
import { FormDataEncoder } from 'form-data-encoder';
|
|
@@ -62,7 +62,7 @@ class BlobFromStream {
|
|
|
62
62
|
return 'Blob';
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.27.
|
|
65
|
+
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.27.3');
|
|
66
66
|
function getFileName(stream) {
|
|
67
67
|
const filePath = stream.path;
|
|
68
68
|
if (filePath) {
|
|
@@ -106,7 +106,20 @@ export class HttpClient extends EventEmitter {
|
|
|
106
106
|
initDiagnosticsChannel();
|
|
107
107
|
}
|
|
108
108
|
getDispatcher() {
|
|
109
|
-
|
|
109
|
+
if (this.#dispatcher) {
|
|
110
|
+
return this.#dispatcher;
|
|
111
|
+
}
|
|
112
|
+
// In a multi-version undici environment
|
|
113
|
+
// the global dispatcher is the highest version of undici
|
|
114
|
+
// which will conflict with the maxRedirects field and report an error
|
|
115
|
+
// so we need to create it that use 5.x version
|
|
116
|
+
const globalDispatcher = getGlobalDispatcher();
|
|
117
|
+
if (!(globalDispatcher instanceof Agent) && !(globalDispatcher instanceof MockAgent)) {
|
|
118
|
+
const dispatcher = globalDispatcher.constructor.name === 'MockAgent' ? new MockAgent() : new Agent();
|
|
119
|
+
this.setDispatcher(dispatcher);
|
|
120
|
+
return dispatcher;
|
|
121
|
+
}
|
|
122
|
+
return globalDispatcher;
|
|
110
123
|
}
|
|
111
124
|
setDispatcher(dispatcher) {
|
|
112
125
|
this.#dispatcher = dispatcher;
|
|
@@ -309,7 +322,7 @@ export class HttpClient extends EventEmitter {
|
|
|
309
322
|
headers,
|
|
310
323
|
bodyTimeout,
|
|
311
324
|
opaque: internalOpaque,
|
|
312
|
-
dispatcher: args.dispatcher ?? this
|
|
325
|
+
dispatcher: args.dispatcher ?? this.getDispatcher(),
|
|
313
326
|
signal: args.signal,
|
|
314
327
|
};
|
|
315
328
|
if (typeof args.highWaterMark === 'number') {
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "urllib",
|
|
3
|
-
"version": "3.27.
|
|
3
|
+
"version": "3.27.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/qs": "^6.9.7",
|
|
71
71
|
"@types/selfsigned": "^2.0.1",
|
|
72
72
|
"@types/tar-stream": "^2.2.2",
|
|
73
|
-
"@vitest/coverage-v8": "^
|
|
73
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
74
74
|
"busboy": "^1.6.0",
|
|
75
75
|
"cross-env": "^7.0.3",
|
|
76
76
|
"eslint": "^8.25.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"tshy": "^1.0.0",
|
|
84
84
|
"tshy-after": "^1.0.0",
|
|
85
85
|
"typescript": "^5.0.4",
|
|
86
|
-
"vitest": "^
|
|
86
|
+
"vitest": "^3.0.0"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": ">= 14.19.3"
|
package/src/HttpClient.ts
CHANGED
|
@@ -22,8 +22,9 @@ import {
|
|
|
22
22
|
request as undiciRequest,
|
|
23
23
|
Dispatcher,
|
|
24
24
|
Agent,
|
|
25
|
-
getGlobalDispatcher,
|
|
26
25
|
Pool,
|
|
26
|
+
getGlobalDispatcher,
|
|
27
|
+
MockAgent,
|
|
27
28
|
} from 'undici';
|
|
28
29
|
import undiciSymbols from 'undici/lib/core/symbols.js';
|
|
29
30
|
import { FormData as FormDataNode } from 'formdata-node';
|
|
@@ -207,10 +208,23 @@ export class HttpClient extends EventEmitter {
|
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
getDispatcher() {
|
|
210
|
-
|
|
211
|
+
if (this.#dispatcher) {
|
|
212
|
+
return this.#dispatcher;
|
|
213
|
+
}
|
|
214
|
+
// In a multi-version undici environment
|
|
215
|
+
// the global dispatcher is the highest version of undici
|
|
216
|
+
// which will conflict with the maxRedirects field and report an error
|
|
217
|
+
// so we need to create it that use 5.x version
|
|
218
|
+
const globalDispatcher = getGlobalDispatcher();
|
|
219
|
+
if (!(globalDispatcher instanceof Agent) && !(globalDispatcher instanceof MockAgent)) {
|
|
220
|
+
const dispatcher = globalDispatcher.constructor.name === 'MockAgent' ? new MockAgent() : new Agent();
|
|
221
|
+
this.setDispatcher(dispatcher);
|
|
222
|
+
return dispatcher;
|
|
223
|
+
}
|
|
224
|
+
return globalDispatcher;
|
|
211
225
|
}
|
|
212
226
|
|
|
213
|
-
setDispatcher(dispatcher
|
|
227
|
+
setDispatcher(dispatcher?: Dispatcher) {
|
|
214
228
|
this.#dispatcher = dispatcher;
|
|
215
229
|
}
|
|
216
230
|
|
|
@@ -415,7 +429,7 @@ export class HttpClient extends EventEmitter {
|
|
|
415
429
|
headers,
|
|
416
430
|
bodyTimeout,
|
|
417
431
|
opaque: internalOpaque,
|
|
418
|
-
dispatcher: args.dispatcher ?? this
|
|
432
|
+
dispatcher: args.dispatcher ?? this.getDispatcher(),
|
|
419
433
|
signal: args.signal,
|
|
420
434
|
};
|
|
421
435
|
if (typeof args.highWaterMark === 'number') {
|