From f67520405323b537101ab4985f4fe2dc96d8e2ae Mon Sep 17 00:00:00 2001 From: Jeremy R Geddes Date: Wed, 29 Mar 2017 16:23:37 -0400 Subject: [PATCH 1/2] get the real length --- lib/postflow/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/postflow/index.js b/lib/postflow/index.js index 8e5dd87..8c9c248 100644 --- a/lib/postflow/index.js +++ b/lib/postflow/index.js @@ -60,7 +60,7 @@ module.exports = function createPostFlowMiddleware(options) { // Check if chunked mode is set if (transferEncoding !== 'chunked') { if (body) { - res.set('Content-Length', body.length); + res.set('Content-Length', Buffer.byteLength(body, 'utf8')); } else { res.set('Content-Length', 0); } From ad6760334b394c4b6a27f814dd71e0f378c641ca Mon Sep 17 00:00:00 2001 From: Jeremy R Geddes Date: Wed, 29 Mar 2017 16:33:59 -0400 Subject: [PATCH 2/2] add comment --- lib/postflow/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/postflow/index.js b/lib/postflow/index.js index 8c9c248..f9f59ea 100644 --- a/lib/postflow/index.js +++ b/lib/postflow/index.js @@ -60,6 +60,7 @@ module.exports = function createPostFlowMiddleware(options) { // Check if chunked mode is set if (transferEncoding !== 'chunked') { if (body) { + // need to get buffer length, not just length (DBCS consideration) res.set('Content-Length', Buffer.byteLength(body, 'utf8')); } else { res.set('Content-Length', 0); @@ -81,4 +82,3 @@ module.exports = function createPostFlowMiddleware(options) { }); }; }; -