aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/undici/lib/core/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/undici/lib/core/util.js')
-rw-r--r--node_modules/undici/lib/core/util.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/node_modules/undici/lib/core/util.js b/node_modules/undici/lib/core/util.js
index 8d5450b..5741650 100644
--- a/node_modules/undici/lib/core/util.js
+++ b/node_modules/undici/lib/core/util.js
@@ -9,6 +9,7 @@ const { InvalidArgumentError } = require('./errors')
const { Blob } = require('buffer')
const nodeUtil = require('util')
const { stringify } = require('querystring')
+const { headerNameLowerCasedRecord } = require('./constants')
const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(v => Number(v))
@@ -218,6 +219,15 @@ function parseKeepAliveTimeout (val) {
return m ? parseInt(m[1], 10) * 1000 : null
}
+/**
+ * Retrieves a header name and returns its lowercase value.
+ * @param {string | Buffer} value Header name
+ * @returns {string}
+ */
+function headerNameToString (value) {
+ return headerNameLowerCasedRecord[value] || value.toLowerCase()
+}
+
function parseHeaders (headers, obj = {}) {
// For H2 support
if (!Array.isArray(headers)) return headers
@@ -489,6 +499,7 @@ module.exports = {
isIterable,
isAsyncIterable,
isDestroyed,
+ headerNameToString,
parseRawHeaders,
parseHeaders,
parseKeepAliveTimeout,