@@ -30,10 +30,11 @@ const std::string JSON_DATA = "{\"hello\":\"world\"}";
3030
3131const string LARGE_DATA = string(1024 * 1024 * 100 , ' @' ); // 100MB
3232
33- MultipartFormData& get_file_value (MultipartFormDataItems &files, const char *key) {
34- auto it = std::find_if (files.begin (), files.end (), [&](const MultipartFormData &file) {
35- return file.name == key;
36- });
33+ MultipartFormData &get_file_value (MultipartFormDataItems &files,
34+ const char *key) {
35+ auto it = std::find_if (
36+ files.begin (), files.end (),
37+ [&](const MultipartFormData &file) { return file.name == key; });
3738 if (it != files.end ()) { return *it; }
3839 throw std::runtime_error (" invalid mulitpart form data name error" );
3940}
@@ -496,15 +497,15 @@ TEST(DigestAuthTest, FromHTTPWatch) {
496497
497498 {
498499 std::vector<std::string> paths = {
499- " /digest-auth/auth/hello/world/MD5" ,
500- " /digest-auth/auth/hello/world/SHA-256" ,
501- " /digest-auth/auth/hello/world/SHA-512" ,
502- " /digest-auth/auth-init/hello/world/MD5" ,
503- " /digest-auth/auth-int/hello/world/MD5" ,
500+ " /digest-auth/auth/hello/world/MD5" ,
501+ " /digest-auth/auth/hello/world/SHA-256" ,
502+ " /digest-auth/auth/hello/world/SHA-512" ,
503+ " /digest-auth/auth-init/hello/world/MD5" ,
504+ " /digest-auth/auth-int/hello/world/MD5" ,
504505 };
505506
506507 cli.set_auth (" hello" , " world" );
507- for (auto path: paths) {
508+ for (auto path : paths) {
508509 auto res = cli.Get (path.c_str ());
509510 ASSERT_TRUE (res != nullptr );
510511 EXPECT_EQ (res->body ,
@@ -801,18 +802,19 @@ class ServerTest : public ::testing::Test {
801802 EXPECT_EQ (" 5" , req.get_header_value (" Content-Length" ));
802803 })
803804 .Post (" /content_receiver" ,
804- [&](const Request & req, Response &res, const ContentReader &content_reader) {
805+ [&](const Request &req, Response &res,
806+ const ContentReader &content_reader) {
805807 if (req.is_multipart_form_data ()) {
806808 MultipartFormDataItems files;
807809 content_reader (
808- [&](const MultipartFormData &file) {
809- files.push_back (file);
810- return true ;
811- },
812- [&](const char *data, size_t data_length) {
813- files.back ().content .append (data, data_length);
814- return true ;
815- });
810+ [&](const MultipartFormData &file) {
811+ files.push_back (file);
812+ return true ;
813+ },
814+ [&](const char *data, size_t data_length) {
815+ files.back ().content .append (data, data_length);
816+ return true ;
817+ });
816818
817819 EXPECT_EQ (5u , files.size ());
818820
@@ -1814,16 +1816,16 @@ TEST_F(ServerTest, MultipartFormDataGzip) {
18141816#endif
18151817
18161818// Sends a raw request to a server listening at HOST:PORT.
1817- static bool send_request (time_t read_timeout_sec, const std::string& req) {
1819+ static bool send_request (time_t read_timeout_sec, const std::string & req) {
18181820 auto client_sock =
18191821 detail::create_client_socket (HOST, PORT, /* timeout_sec=*/ 5 );
18201822
18211823 if (client_sock == INVALID_SOCKET) { return false ; }
18221824
18231825 return detail::process_and_close_socket (
18241826 true , client_sock, 1 , read_timeout_sec, 0 ,
1825- [&](Stream& strm, bool /* last_connection*/ ,
1826- bool & /* connection_close*/ ) -> bool {
1827+ [&](Stream & strm, bool /* last_connection*/ , bool &
1828+ /* connection_close*/ ) -> bool {
18271829 if (req.size () !=
18281830 static_cast <size_t >(strm.write (req.data (), req.size ()))) {
18291831 return false ;
@@ -1840,11 +1842,10 @@ static bool send_request(time_t read_timeout_sec, const std::string& req) {
18401842TEST (ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) {
18411843 Server svr;
18421844 std::string header_value;
1843- svr.Get (" /validate-ws-in-headers" ,
1844- [&](const Request &req, Response &res) {
1845- header_value = req.get_header_value (" foo" );
1846- res.set_content (" ok" , " text/plain" );
1847- });
1845+ svr.Get (" /validate-ws-in-headers" , [&](const Request &req, Response &res) {
1846+ header_value = req.get_header_value (" foo" );
1847+ res.set_content (" ok" , " text/plain" );
1848+ });
18481849
18491850 thread t = thread ([&] { svr.listen (HOST, PORT); });
18501851 while (!svr.is_running ()) {
@@ -1853,11 +1854,10 @@ TEST(ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) {
18531854
18541855 // Only space and horizontal tab are whitespace. Make sure other whitespace-
18551856 // like characters are not treated the same - use vertical tab and escape.
1856- const std::string req =
1857- " GET /validate-ws-in-headers HTTP/1.1\r\n "
1858- " foo: \t \v bar \e\t \r\n "
1859- " Connection: close\r\n "
1860- " \r\n " ;
1857+ const std::string req = " GET /validate-ws-in-headers HTTP/1.1\r\n "
1858+ " foo: \t \v bar \e\t \r\n "
1859+ " Connection: close\r\n "
1860+ " \r\n " ;
18611861
18621862 ASSERT_TRUE (send_request (5 , req));
18631863 svr.stop ();
@@ -1867,10 +1867,9 @@ TEST(ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) {
18671867
18681868TEST (ServerRequestParsingTest, ReadHeadersRegexComplexity) {
18691869 Server svr;
1870- svr.Get (" /hi" ,
1871- [&](const Request & /* req*/ , Response &res) {
1872- res.set_content (" ok" , " text/plain" );
1873- });
1870+ svr.Get (" /hi" , [&](const Request & /* req*/ , Response &res) {
1871+ res.set_content (" ok" , " text/plain" );
1872+ });
18741873
18751874 // Server read timeout must be longer than the client read timeout for the
18761875 // bug to reproduce, probably to force the server to process a request
0 commit comments