Browse Source

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.
yhirose 1 ngày trước cách đây
mục cha
commit
1e35f39675
1 tập tin đã thay đổi với 5 bổ sung và 3 xóa
  1. 5 3
      test/test.cc

+ 5 - 3
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;