From 1e35f396752e763123980d3d0442de9250a36fac Mon Sep 17 00:00:00 2001 From: yhirose Date: Thu, 22 Oct 2026 00:10:34 -0400 Subject: [PATCH] Send the chunk overhead test requests whole before they are refused RejectsChunkOverheadPastItsLimit sent about 78 KB per case, and the server refused the request a few chunks in and closed the connection while the client was still writing, so the send failed now and then instead of returning the 400. Pad each size line with a sixteenth of the limit, so each request is about 10 KB and goes past the limit only at its last chunks. --- test/test.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/test.cc b/test/test.cc index 085c42ef..f63c42c8 100644 --- a/test/test.cc +++ b/test/test.cc @@ -8076,9 +8076,11 @@ TEST_F(ServerTest, RejectsControlCharacterInChunkExtension) { // The bytes around chunk data are no payload, so they cannot ride on the // payload limit TEST_F(ServerTest, RejectsChunkOverheadPastItsLimit) { - auto pad = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 2, 'x'); - auto zeros = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 2, '0'); - auto spaces = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 2, ' '); + // Small enough that the whole request is sent before the server turns it + // down, yet past the limit by the last chunks + auto pad = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 16, 'x'); + auto zeros = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 16, '0'); + auto spaces = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 16, ' '); for (const auto &size_line : {"1;" + pad, zeros + "1", "1" + spaces}) { SCOPED_TRACE(size_line.substr(0, 2)); std::string body;