http-proxy
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -134,3 +134,3 @@ var http = require('http'), | ||
proxyReq.on('response', function(proxyRes) { | ||
if(server) { server.emit('proxyRes', proxyRes); } | ||
if(server) { server.emit('proxyRes', proxyRes, req, res); } | ||
for(var i=0; i < web_o.length; i++) { | ||
@@ -137,0 +137,0 @@ if(web_o[i](req, res, proxyRes)) { break; } |
{ | ||
"name" : "http-proxy", | ||
"version" : "1.1.3", | ||
"version" : "1.1.4", | ||
@@ -5,0 +5,0 @@ "repository" : { |
@@ -130,2 +130,30 @@ var webPasses = require('../lib/http-proxy/passes/web-incoming'), | ||
}); | ||
it('should proxy the request and provide a proxyRes event with the request and response parameters', function(done) { | ||
var proxy = httpProxy.createProxyServer({ | ||
target: 'http://127.0.0.1:8080' | ||
}); | ||
function requestHandler(req, res) { | ||
proxy.once('proxyRes', function (proxyRes, pReq, pRes) { | ||
source.close(); | ||
proxyServer.close(); | ||
expect(pReq).to.be.equal(req); | ||
expect(pRes).to.be.equal(res); | ||
done(); | ||
}); | ||
proxy.web(req, res); | ||
} | ||
var proxyServer = http.createServer(requestHandler); | ||
var source = http.createServer(function(req, res) { | ||
res.end('Response'); | ||
}); | ||
proxyServer.listen('8084'); | ||
source.listen('8080'); | ||
http.request('http://127.0.0.1:8084', function() {}).end(); | ||
}); | ||
}); |
165866
2764