diff --git a/index.js b/index.js index 68013ac..cb63452 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ var net = require('net') , events = require('events') , assert = require('assert') , util = require('util') + , Buffer = require('safe-buffer').Buffer ; exports.httpOverHttp = httpOverHttp @@ -118,7 +119,7 @@ TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { var placeholder = {} self.sockets.push(placeholder) - var connectOptions = mergeOptions({}, self.proxyOptions, + var connectOptions = mergeOptions({}, self.proxyOptions, { method: 'CONNECT' , path: options.host + ':' + options.port , agent: false @@ -183,7 +184,7 @@ TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { var pos = this.sockets.indexOf(socket) if (pos === -1) return - + this.sockets.splice(pos, 1) var pending = this.requests.shift() @@ -198,7 +199,7 @@ function createSecureSocket(options, cb) { var self = this TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, mergeOptions({}, self.options, + var secureSocket = tls.connect(0, mergeOptions({}, self.options, { servername: options.host , socket: socket } diff --git a/package.json b/package.json index a503283..f3c13a2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "files": [ "index.js" ], - "dependencies": {}, + "dependencies": { + "safe-buffer": "^5.0.1" + }, "devDependencies": {}, "optionalDependencies": {}, "engines": {