From d5c60fcc4580c75f82e1593aff30121e19f4ad77 Mon Sep 17 00:00:00 2001 From: kimown Date: Sun, 12 Jun 2016 12:44:25 +0800 Subject: [PATCH] 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. --- doc/api/http.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index 358fdbda9908e7..3e3d3fb0cc92fd 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -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) } };