|
|
@ -1,4 +1,3 @@ |
|
|
|
import http2 from 'spdy'; |
|
|
|
import fetch from 'node-fetch'; |
|
|
|
|
|
|
|
/** |
|
|
@ -20,10 +19,12 @@ export default class Agent { |
|
|
|
} |
|
|
|
|
|
|
|
_initAgent () { |
|
|
|
this._agent = http2.createAgent({ |
|
|
|
/* |
|
|
|
this._agent = https.createAgent({ |
|
|
|
host: this._host, |
|
|
|
port: 443 |
|
|
|
}).once('error', (err) => this._onError(err)); |
|
|
|
*/ |
|
|
|
} |
|
|
|
|
|
|
|
_onError (err) { |
|
|
@ -42,7 +43,7 @@ export default class Agent { |
|
|
|
} |
|
|
|
|
|
|
|
const { body } = opts; |
|
|
|
opts.agent = this._agent; |
|
|
|
// opts.agent = this._agent;
|
|
|
|
|
|
|
|
if (body && 'object' === typeof body && 'function' !== typeof body.pipe) { |
|
|
|
opts.headers['Content-Type'] = 'application/json'; |
|
|
@ -58,6 +59,6 @@ export default class Agent { |
|
|
|
|
|
|
|
close () { |
|
|
|
if (this._debug) console.log('> [debug] closing agent'); |
|
|
|
return this._agent.close(); |
|
|
|
// return this._agent.close();
|
|
|
|
} |
|
|
|
} |
|
|
|