@@ -82,7 +82,7 @@ class MiniRestServer {
8282 ::getsockname (listen_fd_, reinterpret_cast <sockaddr*>(&addr), &len);
8383 port_ = ntohs (addr.sin_port );
8484 if (::listen (listen_fd_, 8 ) < 0 ) return false ;
85- server_thread_ = std::thread ([this ] { Loop (); });
85+ server_thread_ = std::thread ([this , fd = listen_fd_ ] { Loop (fd ); });
8686 return true ;
8787 }
8888
@@ -104,9 +104,9 @@ class MiniRestServer {
104104 }
105105
106106 private:
107- void Loop () {
107+ void Loop (int listen_fd ) {
108108 while (!stopping_) {
109- int fd = ::accept (listen_fd_ , nullptr , nullptr );
109+ int fd = ::accept (listen_fd , nullptr , nullptr );
110110 if (fd < 0 ) break ;
111111 HandleConnection (fd);
112112 ::close (fd);
@@ -128,7 +128,8 @@ class MiniRestServer {
128128 std::string lower;
129129 lower.reserve (header_end);
130130 for (size_t i = 0 ; i < header_end; ++i) {
131- lower.push_back (static_cast <char >(std::tolower (raw[i])));
131+ lower.push_back (
132+ static_cast <char >(std::tolower (static_cast <unsigned char >(raw[i]))));
132133 }
133134 auto pos = lower.find (" content-length:" );
134135 if (pos != std::string::npos) {
@@ -160,7 +161,9 @@ class MiniRestServer {
160161 static std::string HeaderValue (const std::string& headers, std::string_view name) {
161162 std::string lower;
162163 lower.reserve (headers.size ());
163- for (char c : headers) lower.push_back (static_cast <char >(std::tolower (c)));
164+ for (char c : headers) {
165+ lower.push_back (static_cast <char >(std::tolower (static_cast <unsigned char >(c))));
166+ }
164167 auto pos = lower.find (std::string (name) + " :" );
165168 if (pos == std::string::npos) return " " ;
166169 auto value_start = pos + name.size () + 1 ;
@@ -276,10 +279,13 @@ TEST(RestCatalogSessionTest, RefreshAndCommitUseTableSessionFromResponseConfig)
276279 EXPECT_TRUE (requests[0 ].path .find (" /v1/config" ) != std::string::npos);
277280 EXPECT_EQ (requests[0 ].auth_marker , " init" );
278281 EXPECT_EQ (requests[1 ].method , " GET" );
282+ EXPECT_TRUE (requests[1 ].path .find (" /tables/tbl1" ) != std::string::npos);
279283 EXPECT_EQ (requests[1 ].auth_marker , " catalog" );
280284 EXPECT_EQ (requests[2 ].method , " GET" );
285+ EXPECT_TRUE (requests[2 ].path .find (" /tables/tbl1" ) != std::string::npos);
281286 EXPECT_EQ (requests[2 ].auth_marker , " table:tbl-token-1" );
282287 EXPECT_EQ (requests[3 ].method , " POST" );
288+ EXPECT_TRUE (requests[3 ].path .find (" /tables/tbl1" ) != std::string::npos);
283289 EXPECT_EQ (requests[3 ].auth_marker , " table:tbl-token-1" );
284290}
285291
0 commit comments