diff --git a/.gitignore b/.gitignore index c1c03372..a462a6ba 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ node_modules *.log # no Webstorm info at all -.idea/* \ No newline at end of file +.idea/* +/nbproject/private/ +nbproject/ \ No newline at end of file diff --git a/test/test.js b/test/test.js index 2d35bcb2..8d47e2e1 100644 --- a/test/test.js +++ b/test/test.js @@ -67,7 +67,29 @@ describe('http-proxy', function() { }); + + describe('test intercept on html response',function(){ + + it('intercept', function(done) { + var app = express(); + app.use(proxy('httpbin.org', { + intercept: function(data, req, res, cb) { + data = data.toString().replace('Oh','Hey'); + assert(data !== ""); + cb(null, data); + } + })); + request(app) + .get('/html') + .end(function(err, res) { + if (err) return done(err); + assert(res.body.indexOf('Hey') > -1); + done(); + }); + }); + + }); describe('test proxy cookie', function() { it('set cookie', function(done) {