Skip to content

http: improve errors thrown in header validation

Fixes: https://github.com/nodejs/node/issues/16714

This PR:

  • Replace ERR_HTTP2_INVALID_HEADER_VALUE with ERR_HTTP_INVALID_HEADER_VALUE, don't really see a need to differentiate the two.
    • The error code documentation of ERR_HTTP2_INVALID_HEADER_VALUE is kept.
    • Include the header name and the value for debug-ability as https://github.com/nodejs/node/issues/16714 suggests. Before it's Value must not be undefined or null(HTTP2) or The "value" argument must be specified(HTTP), 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, http2

Merge request reports

Loading