Skip to content

Commit

Permalink
doc: use Buffer.byteLength for Content-Length
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kimown authored and Myles Borins committed Jul 14, 2016
1 parent 85f70b3 commit 4a7e333
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ Example:
```js
var body = 'hello world';
response.writeHead(200, {
'Content-Length': body.length,
'Content-Length': Buffer.byteLength(body),
'Content-Type': 'text/plain' });
```

Expand Down Expand Up @@ -1119,7 +1119,7 @@ var options = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': postData.length
'Content-Length': Buffer.byteLength(postData)
}
};

Expand Down

0 comments on commit 4a7e333

Please sign in to comment.