• name {string}

    Performs the low-level validations on the provided name that are done when res.setHeader(name, value) is called.

    Passing illegal value as name will result in a [TypeError][] being thrown, identified by code: 'ERR_INVALID_HTTP_TOKEN'.

    It is not necessary to use this method before passing headers to an HTTP request or response. The HTTP module will automatically validate such headers. Examples:

    Example:

    1. const { validateHeaderName } = require('http');
    2. try {
    3. validateHeaderName('');
    4. } catch (err) {
    5. err instanceof TypeError; // --> true
    6. err.code; // --> 'ERR_INVALID_HTTP_TOKEN'
    7. err.message; // --> 'Header name must be a valid HTTP token [""]'
    8. }