Skip to content

Commit

Permalink
serialize headers (renamed header to headers)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesKyburz committed Oct 11, 2018
1 parent 6675674 commit 017313f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/res.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Object.defineProperty(pinoResProto, rawSymbol, {
function resSerializer (res) {
const _res = Object.create(pinoResProto)
_res.statusCode = res.statusCode
_res.header = res._header
_res.headers = res._headers
_res.raw = res
return _res
}
Expand Down
19 changes: 19 additions & 0 deletions test/res.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,22 @@ test('can wrap response serializers', function (t) {
res.end()
}
})

test('res.headers is serialized', function (t) {
t.plan(1)

var server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})

t.tearDown(() => server.close())

function handler (req, res) {
res.setHeader('x-custom', 'y')
var serialized = serializers.resSerializer(res)
t.is(serialized.headers['x-custom'], 'y')
res.end()
}
})

0 comments on commit 017313f

Please sign in to comment.