mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
doc: show output of example in http
User can check output of example easily. PR-URL: https://github.com/nodejs/node/pull/45915 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
@@ -3664,9 +3664,9 @@ const { validateHeaderName } = require('node:http');
|
||||
try {
|
||||
validateHeaderName('');
|
||||
} catch (err) {
|
||||
err instanceof TypeError; // --> true
|
||||
err.code; // --> 'ERR_INVALID_HTTP_TOKEN'
|
||||
err.message; // --> 'Header name must be a valid HTTP token [""]'
|
||||
console.error(err instanceof TypeError); // --> true
|
||||
console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN'
|
||||
console.error(err.message); // --> 'Header name must be a valid HTTP token [""]'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -3698,17 +3698,17 @@ const { validateHeaderValue } = require('node:http');
|
||||
try {
|
||||
validateHeaderValue('x-my-header', undefined);
|
||||
} catch (err) {
|
||||
err instanceof TypeError; // --> true
|
||||
err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'; // --> true
|
||||
err.message; // --> 'Invalid value "undefined" for header "x-my-header"'
|
||||
console.error(err instanceof TypeError); // --> true
|
||||
console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true
|
||||
console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"'
|
||||
}
|
||||
|
||||
try {
|
||||
validateHeaderValue('x-my-header', 'oʊmɪɡə');
|
||||
} catch (err) {
|
||||
err instanceof TypeError; // --> true
|
||||
err.code === 'ERR_INVALID_CHAR'; // --> true
|
||||
err.message; // --> 'Invalid character in header content ["x-my-header"]'
|
||||
console.error(err instanceof TypeError); // --> true
|
||||
console.error(err.code === 'ERR_INVALID_CHAR'); // --> true
|
||||
console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]'
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user