From 59b94c42ec8cf63d774365688e4502a255cccf0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=97=D0=B0=20=D0=9B=D1=83=D0=BF=D0=BE=D0=B9?= <130570371+zalupoi@users.noreply.github.com> Date: Wed, 12 Apr 2023 17:31:27 +0000 Subject: [PATCH] Fix RFC 7230 violation See https://github.com/nodejs/node/issues/47528 for more details --- src/WebResponses.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp index a22e991aa..a5259076a 100644 --- a/src/WebResponses.cpp +++ b/src/WebResponses.cpp @@ -310,15 +310,14 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u size_t readLen = 0; if(_chunked){ - // HTTP 1.1 allows leading zeros in chunk length. Or spaces may be added. + // HTTP 1.1 allows leading zeros in chunk length. // See RFC2616 sections 2, 3.6.1. readLen = _fillBufferAndProcessTemplates(buf+headLen+6, outLen - 8); if(readLen == RESPONSE_TRY_AGAIN){ free(buf); return 0; } - outLen = sprintf((char*)buf+headLen, "%x", readLen) + headLen; - while(outLen < headLen + 4) buf[outLen++] = ' '; + outLen = sprintf((char*)buf+headLen, "%04x", readLen) + headLen; buf[outLen++] = '\r'; buf[outLen++] = '\n'; outLen += readLen;