Skip to content

Commit 84daab7

Browse files
committed
Remove unreachable code
Node.js < 4.5.0 is no longer supported as per TooTallNate@a2779222.
1 parent e145714 commit 84daab7

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

index.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ HttpsProxyAgent.prototype.callback = function connect(req, opts, fn) {
9191
}
9292

9393
function cleanup() {
94-
socket.removeListener('data', ondata);
9594
socket.removeListener('end', onend);
9695
socket.removeListener('error', onerror);
9796
socket.removeListener('close', onclose);
@@ -120,11 +119,7 @@ HttpsProxyAgent.prototype.callback = function connect(req, opts, fn) {
120119
if (!~str.indexOf('\r\n\r\n')) {
121120
// keep buffering
122121
debug('have not received end of HTTP headers yet...');
123-
if (socket.read) {
124-
read();
125-
} else {
126-
socket.once('data', ondata);
127-
}
122+
read();
128123
return;
129124
}
130125

@@ -174,11 +169,7 @@ HttpsProxyAgent.prototype.callback = function connect(req, opts, fn) {
174169
function onsocket(socket) {
175170
// replay the "buffers" Buffer onto the `socket`, since at this point
176171
// the HTTP module machinery has been hooked up for the user
177-
if ('function' == typeof socket.ondata) {
178-
// node <= v0.11.3, the `ondata` function is set on the socket
179-
socket.ondata(buffers, 0, buffers.length);
180-
} else if (socket.listeners('data').length > 0) {
181-
// node > v0.11.3, the "data" event is listened for directly
172+
if (socket.listenerCount('data') > 0) {
182173
socket.emit('data', buffers);
183174
} else {
184175
// never?
@@ -193,11 +184,7 @@ HttpsProxyAgent.prototype.callback = function connect(req, opts, fn) {
193184
socket.on('close', onclose);
194185
socket.on('end', onend);
195186

196-
if (socket.read) {
197-
read();
198-
} else {
199-
socket.once('data', ondata);
200-
}
187+
read();
201188

202189
var hostname = opts.host + ':' + opts.port;
203190
var msg = 'CONNECT ' + hostname + ' HTTP/1.1\r\n';

0 commit comments

Comments
 (0)