Skip to content
Myr

Fixed multiple Set-Cookie headers via res.header(). Closes #402

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent ab38124 · Browse files · 1 file+23 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−3 removed

  • other:+23 added−3 removed

1 file+23 added−3 removed

modified:lib/express/response.js+23 added-3 removed
15 unmodified lines
16 mime = require('connect/utils').mime,17 Buffer = require('buffer').Buffer;1819/**20 * Header fields supporting multiple values.21 * 22 * @type Array23 */2425var multiple = ['Set-Cookie'];2627/**28 * Send a response with the given `body` and optional `headers` and `status` code.29 *30 * Examples:31 *
145 unmodified lines
177178/**179 * Set or get response header `name` with optional `val`.180 *181 * Headers that may be set multiple times (as indicated by the `multiple` array)182 * can be called with a value several times, for example:183 *184 * res.header('Set-Cookie', '...');185 * res.header('Set-Cookie', '...');186 *187 * @param {String} name188 * @param {String} val189 * @return {String}190 * @api public191 */192193http.ServerResponse.prototype.header = function(name, val){180 return val === undefined181 ? this.headers[name]182 : this.headers[name] = val;194 if (val === undefined) {195 return this.headers[name];196 } else {197 if (this.headers[name] && ~multiple.indexOf(name)) {198 return this.headers[name] += '\r\n' + name + ': ' + val;199 } else {200 return this.headers[name] = val;201 }202 }203};204205/**206 * Redirect to the given `url` with optional response `status`
60 unmodified lines