Skip to content

http: improve errors thrown in header validation

Previously https://github.com/nodejs/node/pull/16715 Fixes: https://github.com/nodejs/node/issues/16714

This PR:

  • Replace ERR_MISSING_ARGS with ERR_HTTP_INVALID_HEADER_VALUE, include the header name and the value for debug-ability as https://github.com/nodejs/node/issues/16714 suggests. Before it's The "value" argument must be specified, after it's Invalid value "undefined" for header "test". If the user is setting the header in a loop this would be much more useful.
  • Use Error.captureStackTrace to exclude the validation functions from the stack trace
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

http

Merge request reports

Loading