Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ res.append = function append(field, val) {
var prev = this.get(field);
var value = val;

if (prev) {
if (prev !== undefined) {
// concat the new and prev vals
value = Array.isArray(prev) ? prev.concat(val)
: Array.isArray(val) ? [prev].concat(val)
Expand Down
15 changes: 15 additions & 0 deletions test/res.append.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ describe('res', function () {
.end(done)
})

it('should preserve an existing empty header value', function (done) {
var app = express()

app.use(function (req, res) {
res.set('Warning', '')
res.append('Warning', '199 Miscellaneous warning')
res.end(JSON.stringify(res.get('Warning')))
})

request(app)
.get('/')
.expect(200, '["","199 Miscellaneous warning"]')
.end(done)
})

it('should work together with res.cookie', function (done) {
var app = express()

Expand Down