Skip to content

Commit dfc2dc8

Browse files
ShogunPandaaduh95
andcommitted
doc: add note about header values encoding
PR-URL: #42624 Fixes: #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>
1 parent b99bb57 commit dfc2dc8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/api/http.md

+12
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,17 @@ or
987987
request.setHeader('Cookie', ['type=ninja', 'language=javascript']);
988988
```
989989

990+
When the value is a string an exception will be thrown if it contains
991+
characters outside the `latin1` encoding.
992+
993+
If you need to pass UTF-8 characters in the value please encode the value
994+
using the [RFC 8187][] standard.
995+
996+
```js
997+
const filename = 'Rock 🎵.txt';
998+
request.setHeader('Content-Disposition', `attachment; filename*=utf-8''${encodeURIComponent(filename)}`);
999+
```
1000+
9901001
### `request.setNoDelay([noDelay])`
9911002

9921003
<!-- YAML
@@ -3406,6 +3417,7 @@ try {
34063417
}
34073418
```
34083419

3420+
[RFC 8187]: https://www.rfc-editor.org/rfc/rfc8187.txt
34093421
[`'checkContinue'`]: #event-checkcontinue
34103422
[`'finish'`]: #event-finish
34113423
[`'request'`]: #event-request

0 commit comments

Comments
 (0)