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.
This commit is contained in:
yhirose committed 2026-10-22 00:10:34 -04:00
1 parent e121385910
commit 1e35f39675
1 file changed
+5 -3
+5 -3
View File
@@ -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;