From f033eb7fd4e5c582d5ede9770413f3057c2e3385 Mon Sep 17 00:00:00 2001 From: RajeshKumar11 Date: Fri, 13 Feb 2026 07:28:09 +0530 Subject: [PATCH] http: add httpValidation option to configure header value validation Add a new httpValidation option to http.createServer() and http.request() / http.ClientRequest that controls how strictly HTTP header values are validated: - 'strict' - reject any non-ASCII or control characters (default) - 'relaxed' - allow the non-ASCII characters permitted by the Fetch specification (kLenientHeaderValueRelaxed) - 'insecure' - disable all validation (like insecureHTTPParser) The option is threaded through _storeHeader -> processHeader -> storeHeader -> validateHeaderValue, and also through writeInformation -> processInformationHeader -> validateHeaderValue. Cannot be used together with insecureHTTPParser. Fixes: https://github.com/nodejs/node/issues/61582 --- doc/api/http.md | 24 + lib/_http_client.js | 27 +- lib/_http_common.js | 42 +- lib/_http_outgoing.js | 72 ++- lib/_http_server.js | 36 +- src/node_http_parser.cc | 16 + .../test-http-header-value-relaxed.js | 429 ++++++++++++++++++ .../parallel/test-http-invalidheaderfield2.js | 73 ++- 8 files changed, 666 insertions(+), 53 deletions(-) create mode 100644 test/parallel/test-http-header-value-relaxed.js diff --git a/doc/api/http.md b/doc/api/http.md index 41ecdf6d00b3be..109f817f30399a 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -3680,6 +3680,9 @@ Found'`.