@@ -334,39 +334,39 @@ TEST(RangeTest, FromHTTPBin) {
334334 httplib::Headers headers;
335335 auto res = cli.Get (" /range/32" , headers);
336336 ASSERT_TRUE (res != nullptr );
337- EXPECT_EQ (res->body , " abcdefghijklmnopqrstuvwxyzabcdef " );
337+ EXPECT_EQ (" abcdefghijklmnopqrstuvwxyzabcdef " , res->body );
338338 EXPECT_EQ (200 , res->status );
339339 }
340340
341341 {
342342 httplib::Headers headers = {httplib::make_range_header ({{1 , -1 }})};
343343 auto res = cli.Get (" /range/32" , headers);
344344 ASSERT_TRUE (res != nullptr );
345- EXPECT_EQ (res->body , " bcdefghijklmnopqrstuvwxyzabcdef " );
345+ EXPECT_EQ (" bcdefghijklmnopqrstuvwxyzabcdef " , res->body );
346346 EXPECT_EQ (206 , res->status );
347347 }
348348
349349 {
350350 httplib::Headers headers = {httplib::make_range_header ({{1 , 10 }})};
351351 auto res = cli.Get (" /range/32" , headers);
352352 ASSERT_TRUE (res != nullptr );
353- EXPECT_EQ (res->body , " bcdefghijk " );
353+ EXPECT_EQ (" bcdefghijk " , res->body );
354354 EXPECT_EQ (206 , res->status );
355355 }
356356
357357 {
358358 httplib::Headers headers = {httplib::make_range_header ({{0 , 31 }})};
359359 auto res = cli.Get (" /range/32" , headers);
360360 ASSERT_TRUE (res != nullptr );
361- EXPECT_EQ (res->body , " abcdefghijklmnopqrstuvwxyzabcdef " );
361+ EXPECT_EQ (" abcdefghijklmnopqrstuvwxyzabcdef " , res->body );
362362 EXPECT_EQ (200 , res->status );
363363 }
364364
365365 {
366366 httplib::Headers headers = {httplib::make_range_header ({{0 , -1 }})};
367367 auto res = cli.Get (" /range/32" , headers);
368368 ASSERT_TRUE (res != nullptr );
369- EXPECT_EQ (res->body , " abcdefghijklmnopqrstuvwxyzabcdef " );
369+ EXPECT_EQ (" abcdefghijklmnopqrstuvwxyzabcdef " , res->body );
370370 EXPECT_EQ (200 , res->status );
371371 }
372372
@@ -440,7 +440,7 @@ TEST(CancelTest, NoCancel) {
440440
441441 auto res = cli.Get (" /range/32" , [](uint64_t , uint64_t ) { return true ; });
442442 ASSERT_TRUE (res != nullptr );
443- EXPECT_EQ (res->body , " abcdefghijklmnopqrstuvwxyzabcdef " );
443+ EXPECT_EQ (" abcdefghijklmnopqrstuvwxyzabcdef " , res->body );
444444 EXPECT_EQ (200 , res->status );
445445}
446446
@@ -501,17 +501,17 @@ TEST(BaseAuthTest, FromHTTPWatch) {
501501 cli.Get (" /basic-auth/hello/world" ,
502502 {httplib::make_basic_authentication_header (" hello" , " world" )});
503503 ASSERT_TRUE (res != nullptr );
504- EXPECT_EQ (res-> body ,
505- " { \n \" authenticated \" : true, \n \" user \" : \" hello \"\n } \n " );
504+ EXPECT_EQ (" { \n \" authenticated \" : true, \n \" user \" : \" hello \"\n } \n " ,
505+ res-> body );
506506 EXPECT_EQ (200 , res->status );
507507 }
508508
509509 {
510510 cli.set_basic_auth (" hello" , " world" );
511511 auto res = cli.Get (" /basic-auth/hello/world" );
512512 ASSERT_TRUE (res != nullptr );
513- EXPECT_EQ (res-> body ,
514- " { \n \" authenticated \" : true, \n \" user \" : \" hello \"\n } \n " );
513+ EXPECT_EQ (" { \n \" authenticated \" : true, \n \" user \" : \" hello \"\n } \n " ,
514+ res-> body );
515515 EXPECT_EQ (200 , res->status );
516516 }
517517
@@ -554,8 +554,8 @@ TEST(DigestAuthTest, FromHTTPWatch) {
554554 for (auto path : paths) {
555555 auto res = cli.Get (path.c_str ());
556556 ASSERT_TRUE (res != nullptr );
557- EXPECT_EQ (res-> body ,
558- " { \n \" authenticated \" : true, \n \" user \" : \" hello \"\n } \n " );
557+ EXPECT_EQ (" { \n \" authenticated \" : true, \n \" user \" : \" hello \"\n } \n " ,
558+ res-> body );
559559 EXPECT_EQ (200 , res->status );
560560 }
561561
@@ -689,7 +689,7 @@ TEST(RedirectToDifferentPort, Redirect) {
689689 auto res = cli.Get (" /1" );
690690 ASSERT_TRUE (res != nullptr );
691691 EXPECT_EQ (200 , res->status );
692- EXPECT_EQ (res-> body , " Hello World!" );
692+ EXPECT_EQ (" Hello World!" , res-> body );
693693
694694 svr8080.stop ();
695695 svr8081.stop ();
@@ -718,15 +718,15 @@ TEST(Server, BindDualStack) {
718718 auto res = cli.Get (" /1" );
719719 ASSERT_TRUE (res != nullptr );
720720 EXPECT_EQ (200 , res->status );
721- EXPECT_EQ (res-> body , " Hello World!" );
721+ EXPECT_EQ (" Hello World!" , res-> body );
722722 }
723723 {
724724 Client cli (" ::1" , PORT);
725725
726726 auto res = cli.Get (" /1" );
727727 ASSERT_TRUE (res != nullptr );
728728 EXPECT_EQ (200 , res->status );
729- EXPECT_EQ (res-> body , " Hello World!" );
729+ EXPECT_EQ (" Hello World!" , res-> body );
730730 }
731731 svr.stop ();
732732 thread.join ();
@@ -808,10 +808,10 @@ class ServerTest : public ::testing::Test {
808808 res.set_content (" slow" , " text/plain" );
809809 })
810810 .Post (" /slowpost" ,
811- [&](const Request & /* req*/ , Response &res) {
812- std::this_thread::sleep_for (std::chrono::seconds (2 ));
813- res.set_content (" slow" , " text/plain" );
814- })
811+ [&](const Request & /* req*/ , Response &res) {
812+ std::this_thread::sleep_for (std::chrono::seconds (2 ));
813+ res.set_content (" slow" , " text/plain" );
814+ })
815815 .Get (" /remote_addr" ,
816816 [&](const Request &req, Response &res) {
817817 auto remote_addr = req.headers .find (" REMOTE_ADDR" )->second ;
@@ -1893,14 +1893,18 @@ TEST_F(ServerTest, SlowRequest) {
18931893TEST_F (ServerTest, SlowPost) {
18941894 char buffer[64 * 1024 ];
18951895 memset (buffer, 0x42 , sizeof (buffer));
1896+
18961897 auto res = cli_.Post (
1897- " /slowpost" , 64 *1024 *1024 ,
1898- [&] (size_t /* offset*/ , size_t /* length*/ , DataSink & sink) {
1899- sink.write (buffer, sizeof (buffer)); return true ;
1898+ " /slowpost" , 64 * 1024 * 1024 ,
1899+ [&](size_t /* offset*/ , size_t /* length*/ , DataSink &sink) {
1900+ sink.write (buffer, sizeof (buffer));
1901+ return true ;
19001902 },
19011903 " text/plain" );
1904+
19021905 ASSERT_TRUE (res != nullptr );
19031906 EXPECT_EQ (200 , res->status );
1907+
19041908 cli_.set_write_timeout (0 , 0 );
19051909 res = cli_.Post (
19061910 " /slowpost" , 64 * 1024 * 1024 ,
@@ -1909,6 +1913,7 @@ TEST_F(ServerTest, SlowPost) {
19091913 return true ;
19101914 },
19111915 " text/plain" );
1916+
19121917 ASSERT_FALSE (res != nullptr );
19131918}
19141919
@@ -2465,7 +2470,7 @@ TEST(ServerStopTest, StopServerWithChunkedTransmission) {
24652470 svr.Get (" /events" , [](const Request & /* req*/ , Response &res) {
24662471 res.set_header (" Content-Type" , " text/event-stream" );
24672472 res.set_header (" Cache-Control" , " no-cache" );
2468- res.set_chunked_content_provider ([](size_t offset, const DataSink &sink) {
2473+ res.set_chunked_content_provider ([](size_t offset, DataSink &sink) {
24692474 char buffer[27 ];
24702475 auto size = static_cast <size_t >(sprintf (buffer, " data:%ld\n\n " , offset));
24712476 sink.write (buffer, size);
0 commit comments