Skip to content

Commit

Permalink
added headers method
Browse files Browse the repository at this point in the history
  • Loading branch information
Caolan McMahon committed Jun 28, 2010
1 parent c4e8d94 commit 9cf7d30
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/quickresponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ module.exports = function(){
return res;
};

// add headers
res.headers = function(headers){
for(var k in headers) res._headers[k] = headers[k];
return res;
};

// success
res.ok = withStatus(200);
res.created = withStatus(201);
Expand Down
21 changes: 20 additions & 1 deletion test/test-response.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TODO: add support for following styles:
// req.text().notFound('not found');
// req.headers({some:header}).ok('done');

var quickresponse = require('quickresponse');
Expand Down Expand Up @@ -183,3 +182,23 @@ exports['send defaults'] = function(test){
});
test.done();
};

exports.headers = function(test){
test.expect(3);
var res = {};
quickresponse()(null, res, function(){
test.equals(res.headers({some:'header',test:'test'}), res);
test.same(res._headers, {
'Content-Type':'text/html',
some:'header',
test:'test'
});
res.headers({'Content-Type':'test'});
test.same(res._headers, {
'Content-Type':'test',
some:'header',
test:'test'
});
});
test.done();
};

0 comments on commit 9cf7d30

Please sign in to comment.