diff options
author | Shogun <paolo@cowtech.it> | 2022-04-06 11:41:00 +0200 |
---|---|---|
committer | Shogun <paolo@cowtech.it> | 2022-04-08 16:04:41 +0200 |
commit | dfc2dc8b6565da78d493c44aa836482dd422aeed (patch) | |
tree | 380fac73daef6ab1d4cf4cb2aef96c37c00dd4a6 /doc/api | |
parent | b99bb57416f5eabc9d8375b93e03de21d8ed29ee (diff) | |
download | node-new-dfc2dc8b6565da78d493c44aa836482dd422aeed.tar.gz |
doc: add note about header values encoding
PR-URL: https://github.com/nodejs/node/pull/42624
Fixes: https://github.com/nodejs/node/issues/42579
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'doc/api')
-rw-r--r-- | doc/api/http.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/api/http.md b/doc/api/http.md index 86234e2fef..d551b588c8 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -987,6 +987,17 @@ or request.setHeader('Cookie', ['type=ninja', 'language=javascript']); ``` +When the value is a string an exception will be thrown if it contains +characters outside the `latin1` encoding. + +If you need to pass UTF-8 characters in the value please encode the value +using the [RFC 8187][] standard. + +```js +const filename = 'Rock 🎵.txt'; +request.setHeader('Content-Disposition', `attachment; filename*=utf-8''${encodeURIComponent(filename)}`); +``` + ### `request.setNoDelay([noDelay])` <!-- YAML @@ -3406,6 +3417,7 @@ try { } ``` +[RFC 8187]: https://www.rfc-editor.org/rfc/rfc8187.txt [`'checkContinue'`]: #event-checkcontinue [`'finish'`]: #event-finish [`'request'`]: #event-request |