proxy-chain
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -87,4 +87,4 @@ 'use strict'; | ||
// called for the ServerResponse's "finish" event | ||
// XXX: normally, node's "http" module has a "finish" event listener that would | ||
// Called for the ServerResponse's "finish" event | ||
// Normally, Node's "http" module has a "finish" event listener that would | ||
// take care of closing the socket once the HTTP response has completed, but | ||
@@ -150,4 +150,10 @@ // since we're making this ServerResponse instance manually, that event handler | ||
if (this.isClosed) return; | ||
this.log('Source response finished'); | ||
this.close(); | ||
this.log('Source response finished, ending source socket'); | ||
// NOTE: We cannot destroy the socket, since there might be pending data that wouldn't be delivered! | ||
// This code is inspired by resOnFinish() in _http_server.js in Node.js code base. | ||
if (typeof this.srcSocket.destroySoon === 'function') { | ||
this.srcSocket.destroySoon(); | ||
} else { | ||
this.srcSocket.end(); | ||
} | ||
} | ||
@@ -176,5 +182,8 @@ }, { | ||
// If socket is closed here instead of response, phantomjs does not properly parse the response as http response. | ||
if (this.srcResponse) this.srcResponse.end(); | ||
// Handler tunnel chain does not use srcResponse, but needs to close srcSocket | ||
else if (this.srcSocket) this.srcSocket.end(); | ||
if (this.srcResponse) { | ||
this.srcResponse.end(); | ||
} else if (this.srcSocket) { | ||
// Handler tunnel chain does not use srcResponse, but needs to close srcSocket | ||
this.srcSocket.end(); | ||
} | ||
} | ||
@@ -187,5 +196,8 @@ }, { | ||
// If socket is closed here instead of response, phantomjs does not properly parse the response as http response. | ||
if (this.srcResponse) this.srcResponse.end(); | ||
// Handler tunnel chain does not use srcResponse, but needs to close srcSocket | ||
else if (this.srcSocket) this.srcSocket.end(); | ||
if (this.srcResponse) { | ||
this.srcResponse.end(); | ||
} else if (this.srcSocket) { | ||
// Handler tunnel chain does not use srcResponse, but needs to close srcSocket | ||
this.srcSocket.end(); | ||
} | ||
} | ||
@@ -192,0 +204,0 @@ }, { |
@@ -84,3 +84,3 @@ 'use strict'; | ||
}).then(function () { | ||
_this2.log('Custom response sent to source (' + response.statusCode + ')'); | ||
_this2.log('Custom response sent to source'); | ||
}).catch(function (err) { | ||
@@ -87,0 +87,0 @@ if (_this2.isClosed) return; |
@@ -0,1 +1,5 @@ | ||
0.2.4 / 2018-07-27 | ||
=================== | ||
- Bugfix: large custom responses were not delivered completely because the socket was closed too early | ||
0.2.3 / 2018-06-21 | ||
@@ -2,0 +6,0 @@ =================== |
{ | ||
"name": "proxy-chain", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.", | ||
@@ -49,3 +49,3 @@ "main": "build/index.js", | ||
"babel-core": "^6.1.21", | ||
"babel-eslint": "^7.2.2", | ||
"babel-eslint": "^8.2.6", | ||
"babel-preset-es2015": "^6.1.18", | ||
@@ -70,8 +70,8 @@ "babel-preset-stage-0": "^6.1.18", | ||
"request": "^2.83.0", | ||
"sinon": "^5.1.0", | ||
"sinon": "^6.1.4", | ||
"sinon-stub-promise": "^4.0.0", | ||
"through": "^2.3.8", | ||
"ws": "^5.2.0" | ||
"ws": "^6.0.0" | ||
}, | ||
"optionalDependencies": {} | ||
} |
116947
1810