urllib 3.16.0 → 3.16.1
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 +4 -3
- package/src/cjs/HttpClient.js +1 -1
- package/src/cjs/index.js +14 -6
- package/src/esm/HttpClient.js +1 -1
- package/src/esm/index.js +11 -6
- package/src/index.ts +12 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "urllib",
|
3
|
-
"version": "3.16.
|
3
|
+
"version": "3.16.1",
|
4
4
|
"publishConfig": {
|
5
5
|
"tag": "latest"
|
6
6
|
},
|
@@ -67,7 +67,8 @@
|
|
67
67
|
"formstream": "^1.1.1",
|
68
68
|
"mime-types": "^2.1.35",
|
69
69
|
"pump": "^3.0.0",
|
70
|
-
"undici": "^5.22.1"
|
70
|
+
"undici": "^5.22.1",
|
71
|
+
"ylru": "^1.3.2"
|
71
72
|
},
|
72
73
|
"devDependencies": {
|
73
74
|
"@types/busboy": "^1.5.0",
|
@@ -87,7 +88,7 @@
|
|
87
88
|
"selfsigned": "^2.0.1",
|
88
89
|
"tar-stream": "^2.2.0",
|
89
90
|
"typescript": "^5.0.4",
|
90
|
-
"vitest": "^0.
|
91
|
+
"vitest": "^0.31.1"
|
91
92
|
},
|
92
93
|
"engines": {
|
93
94
|
"node": ">= 14.19.3"
|
package/src/cjs/HttpClient.js
CHANGED
@@ -69,7 +69,7 @@ class HttpClientRequestTimeoutError extends Error {
|
|
69
69
|
Error.captureStackTrace(this, this.constructor);
|
70
70
|
}
|
71
71
|
}
|
72
|
-
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.16.
|
72
|
+
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.16.1');
|
73
73
|
function getFileName(stream) {
|
74
74
|
const filePath = stream.path;
|
75
75
|
if (filePath) {
|
package/src/cjs/index.js
CHANGED
@@ -1,18 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.USER_AGENT = exports.HttpClient2 = exports.HttpClient = exports.getGlobalDispatcher = exports.setGlobalDispatcher = exports.Dispatcher = exports.Agent = exports.ProxyAgent = exports.MockAgent = exports.curl = exports.request = void 0;
|
7
|
+
const ylru_1 = __importDefault(require("ylru"));
|
4
8
|
const HttpClient_1 = require("./HttpClient");
|
5
9
|
let httpclient;
|
10
|
+
const domainSocketHttpclients = new ylru_1.default(50);
|
6
11
|
async function request(url, options) {
|
7
|
-
if (
|
8
|
-
|
9
|
-
|
12
|
+
if (options?.socketPath) {
|
13
|
+
let domainSocketHttpclient = domainSocketHttpclients.get(options.socketPath);
|
14
|
+
if (!domainSocketHttpclient) {
|
15
|
+
domainSocketHttpclient = new HttpClient_1.HttpClient({
|
10
16
|
connect: { socketPath: options.socketPath },
|
11
17
|
});
|
18
|
+
domainSocketHttpclients.set(options.socketPath, domainSocketHttpclient);
|
12
19
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
20
|
+
return await domainSocketHttpclient.request(url, options);
|
21
|
+
}
|
22
|
+
if (!httpclient) {
|
23
|
+
httpclient = new HttpClient_1.HttpClient({});
|
16
24
|
}
|
17
25
|
return await httpclient.request(url, options);
|
18
26
|
}
|
package/src/esm/HttpClient.js
CHANGED
@@ -63,7 +63,7 @@ class HttpClientRequestTimeoutError extends Error {
|
|
63
63
|
Error.captureStackTrace(this, this.constructor);
|
64
64
|
}
|
65
65
|
}
|
66
|
-
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.16.
|
66
|
+
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.16.1');
|
67
67
|
function getFileName(stream) {
|
68
68
|
const filePath = stream.path;
|
69
69
|
if (filePath) {
|
package/src/esm/index.js
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
+
import LRU from 'ylru';
|
1
2
|
import { HttpClient, HEADER_USER_AGENT } from './HttpClient.js';
|
2
3
|
let httpclient;
|
4
|
+
const domainSocketHttpclients = new LRU(50);
|
3
5
|
export async function request(url, options) {
|
4
|
-
if (
|
5
|
-
|
6
|
-
|
6
|
+
if (options?.socketPath) {
|
7
|
+
let domainSocketHttpclient = domainSocketHttpclients.get(options.socketPath);
|
8
|
+
if (!domainSocketHttpclient) {
|
9
|
+
domainSocketHttpclient = new HttpClient({
|
7
10
|
connect: { socketPath: options.socketPath },
|
8
11
|
});
|
12
|
+
domainSocketHttpclients.set(options.socketPath, domainSocketHttpclient);
|
9
13
|
}
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
return await domainSocketHttpclient.request(url, options);
|
15
|
+
}
|
16
|
+
if (!httpclient) {
|
17
|
+
httpclient = new HttpClient({});
|
13
18
|
}
|
14
19
|
return await httpclient.request(url, options);
|
15
20
|
}
|
package/src/index.ts
CHANGED
@@ -1,16 +1,23 @@
|
|
1
|
+
import LRU from 'ylru';
|
1
2
|
import { HttpClient, HEADER_USER_AGENT } from './HttpClient';
|
2
3
|
import { RequestOptions, RequestURL } from './Request';
|
3
4
|
|
4
5
|
let httpclient: HttpClient;
|
6
|
+
const domainSocketHttpclients = new LRU(50);
|
5
7
|
export async function request<T = any>(url: RequestURL, options?: RequestOptions) {
|
6
|
-
if (
|
7
|
-
|
8
|
-
|
8
|
+
if (options?.socketPath) {
|
9
|
+
let domainSocketHttpclient = domainSocketHttpclients.get<HttpClient>(options.socketPath);
|
10
|
+
if (!domainSocketHttpclient) {
|
11
|
+
domainSocketHttpclient = new HttpClient({
|
9
12
|
connect: { socketPath: options.socketPath },
|
10
13
|
});
|
11
|
-
|
12
|
-
httpclient = new HttpClient({});
|
14
|
+
domainSocketHttpclients.set(options.socketPath, domainSocketHttpclient);
|
13
15
|
}
|
16
|
+
return await domainSocketHttpclient.request<T>(url, options);
|
17
|
+
}
|
18
|
+
|
19
|
+
if (!httpclient) {
|
20
|
+
httpclient = new HttpClient({});
|
14
21
|
}
|
15
22
|
return await httpclient.request<T>(url, options);
|
16
23
|
}
|