Skip to content

Commit 4a7e333

Browse files
kimownMyles Borins
authored and
Myles Borins
committed
doc: use Buffer.byteLength for Content-Length
As the description in http.md: > If the body contains higher coded characters then Buffer.byteLength() should be used to determine the number of bytes in a given encoding. PR-URL: #7274 Reviewed-By: Brian White <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jackson Tian <[email protected]>
1 parent 85f70b3 commit 4a7e333

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/api/http.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ Example:
809809
```js
810810
var body = 'hello world';
811811
response.writeHead(200, {
812-
'Content-Length': body.length,
812+
'Content-Length': Buffer.byteLength(body),
813813
'Content-Type': 'text/plain' });
814814
```
815815

@@ -1119,7 +1119,7 @@ var options = {
11191119
method: 'POST',
11201120
headers: {
11211121
'Content-Type': 'application/x-www-form-urlencoded',
1122-
'Content-Length': postData.length
1122+
'Content-Length': Buffer.byteLength(postData)
11231123
}
11241124
};
11251125

0 commit comments

Comments
 (0)