From a61f1ff273f996de85b17cd43a119d57543c1093 Mon Sep 17 00:00:00 2001 From: sidwebworks Date: Wed, 24 Aug 2022 22:19:29 +0530 Subject: [PATCH] http: throw error on content-length mismatch PR-URL: https://github.com/nodejs/node/pull/44378 Reviewed-By: Matteo Collina Reviewed-By: Robert Nagy --- doc/api/errors.md | 6 ++ doc/api/http.md | 15 ++-- lib/_http_outgoing.js | 41 +++++++++- lib/internal/errors.js | 2 + .../test-http-content-length-mismatch.js | 80 +++++++++++++++++++ .../parallel/test-http-outgoing-properties.js | 2 +- ...test-http-response-multi-content-length.js | 2 +- 7 files changed, 140 insertions(+), 8 deletions(-) create mode 100644 test/parallel/test-http-content-length-mismatch.js diff --git a/doc/api/errors.md b/doc/api/errors.md index 4c31a19fed3338..a4f6902be32d63 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1306,6 +1306,12 @@ When using [`fs.cp()`][], `src` or `dest` pointed to an invalid path. +### `ERR_HTTP_CONTENT_LENGTH_MISMATCH` + +Response body size doesn't match with the specified content-length header value. + + + ### `ERR_FS_CP_FIFO_PIPE`