Skip to content

Commit

Permalink
move the patch to the response proto
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanong committed Mar 6, 2014
1 parent 74f55a8 commit 3112f92
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 45 deletions.
3 changes: 0 additions & 3 deletions lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ var proto = require('./application')
, req = require('./request')
, res = require('./response')

// monkey patch ServerResponse methods
require('./patch')

/**
* Expose `createApplication()`.
*/
Expand Down
41 changes: 0 additions & 41 deletions lib/patch.js

This file was deleted.

24 changes: 23 additions & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ var http = require('http')
, resolve = require('url').resolve
, basename = path.basename
, extname = path.extname
, mime = send.mime
, mime = send.mime;
var ServerResponse = http.ServerResponse;
var setHeader = ServerResponse.prototype.setHeader;

/**
* Response prototype.
Expand Down Expand Up @@ -779,3 +781,23 @@ res.render = function(view, options, fn){
// render
app.render(view, options, fn);
};


/**
* Set header `field` to `val`, special-casing
* the `Set-Cookie` field for multiple support.
*
* @param {String} field
* @param {String} val
* @api public
*/

res.setHeader = function(field, val){
var key = field.toLowerCase();

if ('content-type' == key && this.charset) {
val += '; charset=' + this.charset;
}

return setHeader.call(this, field, val);
};

0 comments on commit 3112f92

Please sign in to comment.