From bfb9356942773f2163f10ff2fe9fd1caea474a95 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 13 May 2019 13:00:17 +0200 Subject: [PATCH] http: do not default to chunked encoding for TRACE Fixes: https://github.com/nodejs/node/issues/25783 PR-URL: https://github.com/nodejs/node/pull/27673 Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Yongsheng Zhang Reviewed-By: Rich Trott Reviewed-By: James M Snell --- lib/_http_client.js | 1 + test/parallel/test-http-client-default-headers-exist.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index 75c86acf2c510c..bc2c2af8acd609 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -180,6 +180,7 @@ function ClientRequest(input, options, cb) { method === 'HEAD' || method === 'DELETE' || method === 'OPTIONS' || + method === 'TRACE' || method === 'CONNECT') { this.useChunkedEncodingByDefault = false; } else { diff --git a/test/parallel/test-http-client-default-headers-exist.js b/test/parallel/test-http-client-default-headers-exist.js index e0cf82e46220c4..ba4d4fa660b2cc 100644 --- a/test/parallel/test-http-client-default-headers-exist.js +++ b/test/parallel/test-http-client-default-headers-exist.js @@ -31,7 +31,8 @@ const expectedHeaders = { 'HEAD': ['host', 'connection'], 'OPTIONS': ['host', 'connection'], 'POST': ['host', 'connection', 'content-length'], - 'PUT': ['host', 'connection', 'content-length'] + 'PUT': ['host', 'connection', 'content-length'], + 'TRACE': ['host', 'connection'] }; const expectedMethods = Object.keys(expectedHeaders);