MCPcopy Index your code
hub / github.com/nodejs/node / checkIsHttpToken

Function checkIsHttpToken

lib/_http_common.js:243–257  ·  view source on GitHub ↗

* Verifies that the given val is a valid HTTP token * per the rules defined in RFC 7230 * See https://tools.ietf.org/html/rfc7230#section-3.2.6 * @param {string} val * @returns {boolean}

(val)

Source from the content-addressed store, hash-verified

241 * @returns {boolean}
242 */
243function checkIsHttpToken(val) {
244 if (val.length >= 10) {
245 return tokenRegExp.test(val);
246 }
247
248 if (val.length === 0) return false;
249
250 // Use lookup table for short strings, regex for longer ones
251 for (let i = 0; i < val.length; i++) {
252 if (!validTokenChars[val.charCodeAt(i)]) {
253 return false;
254 }
255 }
256 return true;
257}
258
259// Strict header value regex per RFC 7230 (original/default behavior):
260// field-value = *( field-content / obs-fold )

Callers 7

ClientRequestFunction · 0.85
_http_outgoing.jsFile · 0.85
processHeaderFunction · 0.85
[kSetHeader]Method · 0.85
[kAppendHeader]Method · 0.85
writeEarlyHintsMethod · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…