mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
19 lines
448 B
JavaScript
19 lines
448 B
JavaScript
'use strict';
|
|
|
|
const Agent = require('agentkeepalive');
|
|
const HttpsAgent = require('agentkeepalive').HttpsAgent;
|
|
const urllib = require('urllib');
|
|
|
|
module.exports = app => {
|
|
const HttpClient = app.config.httpclient.enableDNSCache ?
|
|
require('./dnscache_httpclient') : urllib.HttpClient;
|
|
|
|
const config = app.config.httpclient;
|
|
|
|
return new HttpClient({
|
|
app,
|
|
agent: new Agent(config),
|
|
httpsAgent: new HttpsAgent(config),
|
|
});
|
|
};
|