mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
f
This commit is contained in:
parent
6a67a1d7e0
commit
140ad0c049
@ -304,7 +304,7 @@ module.exports = appInfo => {
|
||||
* @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
|
||||
* @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
|
||||
* @property {Boolean} useHttpClientNext - use urllib@3 HttpClient, default is false
|
||||
* @property {Boolean} allowH2 - use urllib@4 HttpClient and enable H2, default is false
|
||||
* @property {Boolean} allowH2 - use urllib@4 HttpClient and enable H2, default is false. Only works on Node.js >= 18
|
||||
*/
|
||||
config.httpclient = {
|
||||
enableDNSCache: false,
|
||||
|
||||
@ -14,13 +14,19 @@ const Messenger = require('./core/messenger');
|
||||
const DNSCacheHttpClient = require('./core/dnscache_httpclient');
|
||||
const HttpClient = require('./core/httpclient');
|
||||
const HttpClientNext = require('./core/httpclient_next');
|
||||
const HttpClient4 = require('./core/httpclient4');
|
||||
const createLoggers = require('./core/logger');
|
||||
const Singleton = require('./core/singleton');
|
||||
const utils = require('./core/utils');
|
||||
const BaseContextClass = require('./core/base_context_class');
|
||||
const BaseHookClass = require('./core/base_hook_class');
|
||||
|
||||
let HttpClient4 = HttpClientNext;
|
||||
const mainNodejsVersion = parseInt(process.versions.node.split('.')[0]);
|
||||
if (mainNodejsVersion >= 18) {
|
||||
// urllib@4 only works on Node.js >= 18
|
||||
HttpClient4 = require('./core/httpclient4');
|
||||
}
|
||||
|
||||
const HTTPCLIENT = Symbol('EggApplication#httpclient');
|
||||
const LOGGERS = Symbol('EggApplication#loggers');
|
||||
const EGG_PATH = Symbol.for('egg#eggPath');
|
||||
|
||||
4
test/fixtures/apps/httpclient-tracer/app.js
vendored
4
test/fixtures/apps/httpclient-tracer/app.js
vendored
@ -28,14 +28,14 @@ module.exports = app => {
|
||||
});
|
||||
assert(res.status === 200);
|
||||
|
||||
res = await httpclient.request('https://github.com', {
|
||||
res = await httpclient.request('https://registry.npmmirror.com', {
|
||||
method: 'GET',
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
assert(res.status === 200);
|
||||
|
||||
res = await httpclient.request('https://www.npmjs.com', {
|
||||
res = await httpclient.request('https://npmmirror.com', {
|
||||
method: 'GET',
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
@ -589,13 +589,13 @@ describe('test/lib/core/httpclient.test.js', () => {
|
||||
});
|
||||
assert(res.status === 200);
|
||||
|
||||
res = await httpclient.request('https://github.com', {
|
||||
res = await httpclient.request('https://registry.npmmirror.com', {
|
||||
method: 'GET',
|
||||
timeout: 20000,
|
||||
});
|
||||
assert(res.status === 200);
|
||||
|
||||
res = await httpclient.request('https://www.npmjs.com', {
|
||||
res = await httpclient.request('https://npmmirror.com', {
|
||||
method: 'GET',
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user