function getResponseHeaders(res) {
    if (res.getHeaderNames && res.getHeader) {
        return res.getHeaderNames().reduce(function reduce(prev, curr) {
            var header = {};
            header[curr] = res.getHeader(curr);
            return Object.assign({}, prev, header);
        }, {});
    }
    return res._headers;
}
Utility to get response headers from a given response.
Manually generates a POJO from `res.getHeaderNames` and `res.getHeader`,
if available, falling back to deprecated `res._headers`, otherwise.
Intentionally does not use `res.getHeaders` to avoid deserialization
issues with object returned by that method.

@param {http.ServerResponse} res - the OutgoingMessage
@private
@function getResponseHeaders
@returns {object} map from header name to header value
@see https://github.com/restify/node-restify/issues/1370