From f158656e4c5fcb93279463e3a97ac4db8ce2ceec 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 0608cacce13ec0..2c2618b42b6030 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1325,6 +1325,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`