@@ -292,6 +292,9 @@ class ServerTest : public ::testing::Test {
292292 res.status = 404 ;
293293 }
294294 })
295+ .post (" /chunked" , [&](const Request& req, Response& /* res*/ ) {
296+ EXPECT_EQ (req.body , " dechunked post body" );
297+ })
295298 .post (" /multipart" , [&](const Request& req, Response& /* res*/ ) {
296299 EXPECT_EQ (5u , req.files .size ());
297300 ASSERT_TRUE (!req.has_file (" ???" ));
@@ -660,6 +663,34 @@ TEST_F(ServerTest, CaseInsensitiveHeaderName)
660663 EXPECT_EQ (" Hello World!" , res->body );
661664}
662665
666+ TEST_F (ServerTest, CaseInsensitiveTransferEncoding)
667+ {
668+ Request req;
669+ req.method = " POST" ;
670+ req.path = " /chunked" ;
671+
672+ std::string host_and_port;
673+ host_and_port += HOST;
674+ host_and_port += " :" ;
675+ host_and_port += std::to_string (PORT);
676+
677+ req.headers .emplace (" Host" , host_and_port.c_str ());
678+ req.headers .emplace (" Accept" , " */*" );
679+ req.headers .emplace (" User-Agent" , " cpp-httplib/0.1" );
680+ req.headers .emplace (" Content-Type" , " text/plain" );
681+ req.headers .emplace (" Content-Length" , " 0" );
682+ req.headers .emplace (" Transfer-Encoding" , " Chunked" ); // Note, "Chunked" rather than typical "chunked".
683+
684+ // Client does not chunk, so make a chunked body manually.
685+ req.body = " 4\r\n dech\r\n f\r\n unked post body\r\n 0\r\n\r\n " ;
686+
687+ auto res = std::make_shared<Response>();
688+ auto ret = cli_.send (req, *res);
689+
690+ ASSERT_TRUE (ret);
691+ EXPECT_EQ (200 , res->status );
692+ }
693+
663694TEST_F (ServerTest, GetMethodRemoteAddr)
664695{
665696 auto res = cli_.get (" /remote_addr" );
0 commit comments