Skip to content

Commit 77d6bfd

Browse files
ShogunPandaaduh95
authored andcommitted
doc: add note about header values encoding
PR-URL: #42624 Fixes: #42579 Co-authored-by: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 93c9402 commit 77d6bfd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/api/http.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,17 @@ or
979979
request.setHeader('Cookie', ['type=ninja', 'language=javascript']);
980980
```
981981

982+
When the value is a string an exception will be thrown if it contains
983+
characters outside the `latin1` encoding.
984+
985+
If you need to pass UTF-8 characters in the value please encode the value
986+
using the [RFC 8187][] standard.
987+
988+
```js
989+
const filename = 'Rock 🎵.txt';
990+
request.setHeader('Content-Disposition', `attachment; filename*=utf-8''${encodeURIComponent(filename)}`);
991+
```
992+
982993
### `request.setNoDelay([noDelay])`
983994

984995
<!-- YAML
@@ -3387,6 +3398,7 @@ try {
33873398
}
33883399
```
33893400

3401+
[RFC 8187]: https://www.rfc-editor.org/rfc/rfc8187.txt
33903402
[`'checkContinue'`]: #event-checkcontinue
33913403
[`'finish'`]: #event-finish
33923404
[`'request'`]: #event-request

0 commit comments

Comments
 (0)