30 lines
3.9 KiB
JavaScript
30 lines
3.9 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.lowerCaseHeaderNames = exports.convertToOutgoingHttpHeaders = exports.convertToHeaderEntries = void 0;
|
||
|
function convertToHeaderEntries(headers) {
|
||
|
return Object.entries(headers).map(([name, value]) => {
|
||
|
let resultValue = '';
|
||
|
if (value)
|
||
|
resultValue = Array.isArray(value) ? value.toString() : value;
|
||
|
return { name, value: resultValue };
|
||
|
});
|
||
|
}
|
||
|
exports.convertToHeaderEntries = convertToHeaderEntries;
|
||
|
function convertToOutgoingHttpHeaders(headers) {
|
||
|
if (!headers)
|
||
|
return {};
|
||
|
return headers.reduce((result, header) => {
|
||
|
result[header.name.toLowerCase()] = header.value;
|
||
|
return result;
|
||
|
}, {});
|
||
|
}
|
||
|
exports.convertToOutgoingHttpHeaders = convertToOutgoingHttpHeaders;
|
||
|
function lowerCaseHeaderNames(headers) {
|
||
|
const result = {};
|
||
|
Object.keys(headers).forEach(name => {
|
||
|
result[name.toLowerCase()] = headers[name];
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
exports.lowerCaseHeaderNames = lowerCaseHeaderNames;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVhZGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcm94eWxlc3MvdXRpbHMvaGVhZGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFNQSxTQUFnQixzQkFBc0IsQ0FBRSxPQUE0QjtJQUNoRSxPQUFPLE1BQU0sQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxJQUFJLEVBQUUsS0FBSyxDQUFDLEVBQUUsRUFBRTtRQUNqRCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUM7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