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 evanlucas committed Jun 15, 2016
1 parent 5d03bdd commit 8e14f76
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 @@ -859,7 +859,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 @@ -1181,7 +1181,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 8e14f76

Please sign in to comment.