@@ -30,10 +30,11 @@ const std::string JSON_DATA = "{\"hello\":\"world\"}";
30
30
31
31
const string LARGE_DATA = string(1024 * 1024 * 100 , ' @' ); // 100MB
32
32
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; });
37
38
if (it != files.end ()) { return *it; }
38
39
throw std::runtime_error (" invalid mulitpart form data name error" );
39
40
}
@@ -496,15 +497,15 @@ TEST(DigestAuthTest, FromHTTPWatch) {
496
497
497
498
{
498
499
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" ,
504
505
};
505
506
506
507
cli.set_auth (" hello" , " world" );
507
- for (auto path: paths) {
508
+ for (auto path : paths) {
508
509
auto res = cli.Get (path.c_str ());
509
510
ASSERT_TRUE (res != nullptr );
510
511
EXPECT_EQ (res->body ,
@@ -801,18 +802,19 @@ class ServerTest : public ::testing::Test {
801
802
EXPECT_EQ (" 5" , req.get_header_value (" Content-Length" ));
802
803
})
803
804
.Post (" /content_receiver" ,
804
- [&](const Request & req, Response &res, const ContentReader &content_reader) {
805
+ [&](const Request &req, Response &res,
806
+ const ContentReader &content_reader) {
805
807
if (req.is_multipart_form_data ()) {
806
808
MultipartFormDataItems files;
807
809
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
+ });
816
818
817
819
EXPECT_EQ (5u , files.size ());
818
820
@@ -1814,16 +1816,16 @@ TEST_F(ServerTest, MultipartFormDataGzip) {
1814
1816
#endif
1815
1817
1816
1818
// 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) {
1818
1820
auto client_sock =
1819
1821
detail::create_client_socket (HOST, PORT, /* timeout_sec=*/ 5 );
1820
1822
1821
1823
if (client_sock == INVALID_SOCKET) { return false ; }
1822
1824
1823
1825
return detail::process_and_close_socket (
1824
1826
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 {
1827
1829
if (req.size () !=
1828
1830
static_cast <size_t >(strm.write (req.data (), req.size ()))) {
1829
1831
return false ;
@@ -1840,11 +1842,10 @@ static bool send_request(time_t read_timeout_sec, const std::string& req) {
1840
1842
TEST (ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) {
1841
1843
Server svr;
1842
1844
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
+ });
1848
1849
1849
1850
thread t = thread ([&] { svr.listen (HOST, PORT); });
1850
1851
while (!svr.is_running ()) {
@@ -1853,11 +1854,10 @@ TEST(ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) {
1853
1854
1854
1855
// Only space and horizontal tab are whitespace. Make sure other whitespace-
1855
1856
// 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 " ;
1861
1861
1862
1862
ASSERT_TRUE (send_request (5 , req));
1863
1863
svr.stop ();
@@ -1867,10 +1867,9 @@ TEST(ServerRequestParsingTest, TrimWhitespaceFromHeaderValues) {
1867
1867
1868
1868
TEST (ServerRequestParsingTest, ReadHeadersRegexComplexity) {
1869
1869
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
+ });
1874
1873
1875
1874
// Server read timeout must be longer than the client read timeout for the
1876
1875
// bug to reproduce, probably to force the server to process a request
0 commit comments