@@ -6298,6 +6298,53 @@ TEST(MultipartFormDataTest, CloseDelimiterWithoutCRLF) {
62986298 ASSERT_EQ (" 200" , resonse.substr (9 , 3 ));
62996299}
63006300
6301+ TEST (MultipartFormDataTest, ContentLength) {
6302+ auto handled = false ;
6303+
6304+ Server svr;
6305+ svr.Post (" /test" , [&](const Request &req, Response &) {
6306+ ASSERT_EQ (2u , req.files .size ());
6307+
6308+ auto it = req.files .begin ();
6309+ ASSERT_EQ (" text1" , it->second .name );
6310+ ASSERT_EQ (" text1" , it->second .content );
6311+
6312+ ++it;
6313+ ASSERT_EQ (" text2" , it->second .name );
6314+ ASSERT_EQ (" text2" , it->second .content );
6315+
6316+ handled = true ;
6317+ });
6318+
6319+ thread t = thread ([&] { svr.listen (HOST, PORT); });
6320+ auto se = detail::scope_exit ([&] {
6321+ svr.stop ();
6322+ t.join ();
6323+ ASSERT_FALSE (svr.is_running ());
6324+ ASSERT_TRUE (handled);
6325+ });
6326+
6327+ svr.wait_until_ready ();
6328+
6329+ auto req = " POST /test HTTP/1.1\r\n "
6330+ " Content-Type: multipart/form-data;boundary=--------\r\n "
6331+ " Content-Length: 167\r\n "
6332+ " \r\n ----------\r\n "
6333+ " Content-Disposition: form-data; name=\" text1\"\r\n "
6334+ " Content-Length: 5\r\n "
6335+ " \r\n "
6336+ " text1"
6337+ " \r\n ----------\r\n "
6338+ " Content-Disposition: form-data; name=\" text2\"\r\n "
6339+ " \r\n "
6340+ " text2"
6341+ " \r\n ------------\r\n " ;
6342+
6343+ std::string resonse;
6344+ ASSERT_TRUE (send_request (1 , req, &resonse));
6345+ ASSERT_EQ (" 200" , resonse.substr (9 , 3 ));
6346+ }
6347+
63016348#endif
63026349
63036350#ifndef _WIN32
0 commit comments