diff options
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r-- | ext/node/polyfills/_http_outgoing.ts | 32 | ||||
-rw-r--r-- | ext/node/polyfills/http.ts | 5 |
2 files changed, 23 insertions, 14 deletions
diff --git a/ext/node/polyfills/_http_outgoing.ts b/ext/node/polyfills/_http_outgoing.ts index 0cfc070e6..35526a303 100644 --- a/ext/node/polyfills/_http_outgoing.ts +++ b/ext/node/polyfills/_http_outgoing.ts @@ -820,21 +820,25 @@ Object.defineProperty(OutgoingMessage.prototype, "_headerNames", { ), }); -export const validateHeaderName = hideStackFrames((name) => { - if (typeof name !== "string" || !name || !checkIsHttpToken(name)) { - throw new ERR_INVALID_HTTP_TOKEN("Header name", name); - } -}); +export const validateHeaderName = hideStackFrames( + (name: string, label?: string): void => { + if (typeof name !== "string" || !name || !checkIsHttpToken(name)) { + throw new ERR_INVALID_HTTP_TOKEN(label || "Header name", name); + } + }, +); -export const validateHeaderValue = hideStackFrames((name, value) => { - if (value === undefined) { - throw new ERR_HTTP_INVALID_HEADER_VALUE(value, name); - } - if (checkInvalidHeaderChar(value)) { - debug('Header "%s" contains invalid characters', name); - throw new ERR_INVALID_CHAR("header content", name); - } -}); +export const validateHeaderValue = hideStackFrames( + (name: string, value: string): void => { + if (value === undefined) { + throw new ERR_HTTP_INVALID_HEADER_VALUE(value, name); + } + if (checkInvalidHeaderChar(value)) { + debug('Header "%s" contains invalid characters', name); + throw new ERR_INVALID_CHAR("header content", name); + } + }, +); export function parseUniqueHeadersOption(headers) { if (!Array.isArray(headers)) { diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index bcbf6674f..933a8dbcd 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -38,6 +38,7 @@ import { OutgoingMessage, parseUniqueHeadersOption, validateHeaderName, + validateHeaderValue, } from "ext:deno_node/_http_outgoing.ts"; import { ok as assert } from "node:assert"; import { kOutHeaders } from "ext:deno_node/internal/http.ts"; @@ -1824,6 +1825,8 @@ export { METHODS, OutgoingMessage, STATUS_CODES, + validateHeaderName, + validateHeaderValue, }; export default { Agent, @@ -1840,4 +1843,6 @@ export default { ServerResponse, request, get, + validateHeaderName, + validateHeaderValue, }; |