Files
server/lib/BindingAgent.js
Roman Shtylman a2a58f4c6f refactor with async/await
Trying to be more robust about error handling and failure.
2016-07-09 17:06:13 -07:00

24 lines
685 B
JavaScript

import http from 'http';
import util from 'util';
import assert from 'assert';
// binding agent will return a given options.socket as the socket for the agent
// this is useful if you already have a socket established and want the request
// to use that socket instead of making a new one
function BindingAgent(options) {
options = options || {};
http.Agent.call(this, options);
this.socket = options.socket;
assert(this.socket, 'socket is required for BindingAgent');
this.createConnection = create_connection;
}
util.inherits(BindingAgent, http.Agent);
function create_connection(port, host, options) {
return this.socket;
}
export default BindingAgent;