Skip to content

Commit

Permalink
test intercept on html response
Browse files Browse the repository at this point in the history
  • Loading branch information
topheman committed Dec 10, 2014
1 parent 5f06e47 commit 264e451
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules
*.log

# no Webstorm info at all
.idea/*
.idea/*
/nbproject/private/
nbproject/
22 changes: 22 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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','<strong>Hey</strong>');
assert(data !== "");
cb(null, data);
}
}));

request(app)
.get('/html')
.end(function(err, res) {
if (err) return done(err);
assert(res.body.indexOf('<strong>Hey</strong>') > -1);
done();
});
});

});

describe('test proxy cookie', function() {
it('set cookie', function(done) {
Expand Down

0 comments on commit 264e451

Please sign in to comment.