mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] fixed passes functions, now 'this' can be used and options are stored on 'this.options'
This commit is contained in:
parent
90fb01d38a
commit
9b3e1eb247
@ -64,12 +64,13 @@ var passes = exports;
|
||||
*
|
||||
* @param {ClientRequest} Req Request object
|
||||
* @param {Socket} Websocket
|
||||
* @param {Object} Options Config object passed to the proxy
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function XHeaders(req, socket, options) {
|
||||
function XHeaders(req, socket) {
|
||||
// Now the options are stored on this
|
||||
var options = this.options;
|
||||
if(!options.xfwd) return;
|
||||
|
||||
var values = {
|
||||
@ -92,11 +93,11 @@ var passes = exports;
|
||||
*
|
||||
* @param {ClientRequest} Req Request object
|
||||
* @param {Socket} Websocket
|
||||
* @param {Object} Options Config object passed to the proxy
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
function stream(req, socket, server, head, clb) {
|
||||
function stream(req, socket, head, clb) {
|
||||
var server = this;
|
||||
common.setupSocket(socket);
|
||||
|
||||
if (head && head.length) socket.unshift(head);
|
||||
|
||||
@ -122,7 +122,7 @@ describe('lib/http-proxy.js', function() {
|
||||
proxy.on('error', function (err) {
|
||||
expect(err).to.be.an(Error);
|
||||
expect(err.code).to.be('ECONNREFUSED');
|
||||
proxyServer._server.close();
|
||||
proxy._server.close();
|
||||
done();
|
||||
})
|
||||
|
||||
@ -148,9 +148,7 @@ describe('lib/http-proxy.js', function() {
|
||||
setTimeout(function () {
|
||||
res.end('At this point the socket should be closed');
|
||||
}, 5)
|
||||
});
|
||||
|
||||
source.listen('8080');
|
||||
}).listen('8080');
|
||||
|
||||
var testReq = http.request({
|
||||
hostname: '127.0.0.1',
|
||||
@ -161,6 +159,8 @@ describe('lib/http-proxy.js', function() {
|
||||
testReq.on('error', function (e) {
|
||||
expect(e).to.be.an(Error);
|
||||
expect(e.code).to.be.eql('ECONNRESET');
|
||||
proxy._server.close();
|
||||
source.close();
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user