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: https://github.com/nodejs/node/pull/7274 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
This commit is contained in:
parent
bd23290657
commit
d06820c624
@ -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' });
|
||||
```
|
||||
|
||||
@ -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)
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user