4 * Copyright(c) 2011 TJ Holowaychuk
12 var http = require('http')
13 , res = http.OutgoingMessage.prototype;
15 // original setHeader()
17 var setHeader = res.setHeader;
20 * Set header `field` to `val`, special-casing
21 * the `Set-Cookie` field for multiple support.
23 * @param {String} field
28 res.setHeader = function(field, val){
29 var key = field.toLowerCase()
32 // special-case Set-Cookie
33 if (this._headers && 'set-cookie' == key) {
34 if (prev = this.getHeader(field)) {
35 val = Array.isArray(prev)
40 } else if ('content-type' == key && this.charset) {
41 val += '; charset=' + this.charset;
44 return setHeader.call(this, field, val);