egg 3.27.1 → 3.28.0

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.
@@ -303,8 +303,8 @@ module.exports = appInfo => {
303
303
  * @property {Number} httpsAgent.freeSocketTimeout - httpss agent socket keepalive max free time, default is 4000 ms.
304
304
  * @property {Number} httpsAgent.maxSockets - https agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
305
305
  * @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
306
- * @property {Boolean} useHttpClientNext - use urllib@3 HttpClient
307
- * @property {Boolean} allowH2 - Allow to use HTTP2 first, only work on `useHttpClientNext = true`
306
+ * @property {Boolean} useHttpClientNext - use urllib@3 HttpClient, default is false
307
+ * @property {Boolean} allowH2 - use urllib@4 HttpClient and enable H2, default is false. Only works on Node.js >= 18
308
308
  */
309
309
  config.httpclient = {
310
310
  enableDNSCache: false,
@@ -1,7 +1,16 @@
1
- const { HttpClient } = require('urllib-next');
2
1
  const ms = require('humanize-ms');
2
+
3
3
  const SSRF_HTTPCLIENT = Symbol('SSRF_HTTPCLIENT');
4
4
 
5
+ const mainNodejsVersion = parseInt(process.versions.node.split('.')[0]);
6
+ let HttpClient;
7
+ if (mainNodejsVersion >= 18) {
8
+ // urllib@4 only works on Node.js >= 18
9
+ HttpClient = require('urllib4').HttpClient;
10
+ } else {
11
+ HttpClient = require('urllib-next').HttpClient;
12
+ }
13
+
5
14
  class HttpClientNext extends HttpClient {
6
15
  constructor(app, options) {
7
16
  normalizeConfig(app);
package/lib/egg.js CHANGED
@@ -292,7 +292,7 @@ class EggApplication extends EggCore {
292
292
  */
293
293
  createHttpClient(options) {
294
294
  let httpClient;
295
- if (this.config.httpclient.useHttpClientNext) {
295
+ if (this.config.httpclient.useHttpClientNext || this.config.httpclient.allowH2) {
296
296
  httpClient = new this.HttpClientNext(this, options);
297
297
  } else if (this.config.httpclient.enableDNSCache) {
298
298
  httpClient = new DNSCacheHttpClient(this, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.27.1",
3
+ "version": "3.28.0",
4
4
  "publishConfig": {
5
5
  "tag": "release-3.x",
6
6
  "access": "public"
@@ -55,7 +55,8 @@
55
55
  "onelogger": "^1.0.0",
56
56
  "sendmessage": "^2.0.0",
57
57
  "urllib": "^2.33.0",
58
- "urllib-next": "npm:urllib@^3.26.0",
58
+ "urllib-next": "npm:urllib@^3.27.1",
59
+ "urllib4": "npm:urllib@^4.3.0",
59
60
  "utility": "^2.1.0",
60
61
  "ylru": "^1.3.2"
61
62
  },
@@ -77,7 +78,6 @@
77
78
  "egg-view-nunjucks": "^2.3.0",
78
79
  "eslint": "^8.23.1",
79
80
  "eslint-config-egg": "^12.0.0",
80
- "findlinks": "^2.2.0",
81
81
  "formstream": "^1.1.1",
82
82
  "jsdoc": "^3.6.11",
83
83
  "koa": "^2.13.4",
@@ -85,11 +85,9 @@
85
85
  "node-libs-browser": "^2.2.1",
86
86
  "pedding": "^1.1.0",
87
87
  "prettier": "^2.7.1",
88
- "puppeteer": "^19.11.1",
89
88
  "react": "^16.14.0",
90
89
  "react-dom": "^16.14.0",
91
90
  "react-router": "^5.3.4",
92
- "runscript": "^1.5.3",
93
91
  "sdk-base": "^4.2.1",
94
92
  "spy": "^1.0.0",
95
93
  "supertest": "^6.2.4",