Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4a7e333

Browse filesBrowse files
kimownMyles Borins
authored andcommitted
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 <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
1 parent 85f70b3 commit 4a7e333
Copy full SHA for 4a7e333

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.