Skip to content
Myr

Allow setting an array of header values in the response

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

Make setting multiple header values using an array work as expected. If the header value is an array, coerce the values to strings instead of the entire array. Fixes #1419.

authored by Greg Methvin · committed by Greg Methvin · parent 8beb1f2 · Browse files · 2 files+24 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

2 files+24 added−3 removed

  • tests:+21 added−0 removed
  • other:+3 added−3 removed

2 files+24 added−3 removed

modified:lib/response.js+3 added-3 removed
508 unmodified lines
509 * @api public510 */511512res.set =513res.header = function(field, val){513res.header = function header(field, val){514 if (2 == arguments.length) {515 this.setHeader(field, '' + val);515 this.setHeader(field, Array.isArray(val) ? val.map(String) : String(val));516 } else {517 for (var key in field) {518 this.setHeader(key, '' + field[key]);518 header.call(this, key, field[key]);519 }520 }521 return this;522};
200 unmodified lines
modified:test/res.set.js+21 added