@@ -217,7 +217,8 @@ using socket_t = int;
217217#include < thread>
218218
219219#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
220- // these are defined in wincrypt.h and it breaks compilation if BoringSSL is used
220+ // these are defined in wincrypt.h and it breaks compilation if BoringSSL is
221+ // used
221222#ifdef _WIN32
222223#undef X509_NAME
223224#undef X509_CERT_PAIR
@@ -1951,7 +1952,7 @@ inline std::string base64_encode(const std::string &in) {
19511952
19521953inline bool is_file (const std::string &path) {
19531954#ifdef _WIN32
1954- return ( _access_s (path.c_str (), 0 ) == 0 ) ;
1955+ return _access_s (path.c_str (), 0 ) == 0 ;
19551956#else
19561957 struct stat st;
19571958 return stat (path.c_str (), &st) >= 0 && S_ISREG (st.st_mode );
@@ -2688,25 +2689,29 @@ inline socket_t create_client_socket(
26882689
26892690 {
26902691#ifdef _WIN32
2691- uint32_t timeout = static_cast <uint32_t >(read_timeout_sec * 1000 + read_timeout_usec / 1000 );
2692- setsockopt (sock2, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof (timeout));
2692+ auto timeout = static_cast <uint32_t >(read_timeout_sec * 1000 +
2693+ read_timeout_usec / 1000 );
2694+ setsockopt (sock2, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,
2695+ sizeof (timeout));
26932696#else
2694- timeval tv;
2695- tv.tv_sec = static_cast <long >(read_timeout_sec);
2696- tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec);
2697- setsockopt (sock2, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof (tv));
2697+ timeval tv;
2698+ tv.tv_sec = static_cast <long >(read_timeout_sec);
2699+ tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec);
2700+ setsockopt (sock2, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof (tv));
26982701#endif
26992702 }
27002703 {
27012704
27022705#ifdef _WIN32
2703- uint32_t timeout = static_cast <uint32_t >(write_timeout_sec * 1000 + write_timeout_usec / 1000 );
2704- setsockopt (sock2, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof (timeout));
2706+ auto timeout = static_cast <uint32_t >(write_timeout_sec * 1000 +
2707+ write_timeout_usec / 1000 );
2708+ setsockopt (sock2, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
2709+ sizeof (timeout));
27052710#else
2706- timeval tv;
2707- tv.tv_sec = static_cast <long >(read_timeout_sec);
2708- tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec);
2709- setsockopt (sock2, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof (tv));
2711+ timeval tv;
2712+ tv.tv_sec = static_cast <long >(read_timeout_sec);
2713+ tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec);
2714+ setsockopt (sock2, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof (tv));
27102715#endif
27112716 }
27122717
@@ -5254,29 +5259,33 @@ inline bool Server::listen_internal() {
52545259 break ;
52555260 }
52565261
5257- {
5262+ {
52585263#ifdef _WIN32
5259- uint32_t timeout = static_cast <uint32_t >(read_timeout_sec_ * 1000 + read_timeout_usec_ / 1000 );
5260- setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof (timeout));
5264+ auto timeout = static_cast <uint32_t >(read_timeout_sec_ * 1000 +
5265+ read_timeout_usec_ / 1000 );
5266+ setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,
5267+ sizeof (timeout));
52615268#else
5262- timeval tv;
5263- tv.tv_sec = static_cast <long >(read_timeout_sec_);
5264- tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec_);
5265- setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof (tv));
5269+ timeval tv;
5270+ tv.tv_sec = static_cast <long >(read_timeout_sec_);
5271+ tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec_);
5272+ setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof (tv));
52665273#endif
5267- }
5268- {
5274+ }
5275+ {
52695276
52705277#ifdef _WIN32
5271- uint32_t timeout = static_cast <uint32_t >(write_timeout_sec_ * 1000 + write_timeout_usec_ / 1000 );
5272- setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof (timeout));
5278+ auto timeout = static_cast <uint32_t >(write_timeout_sec_ * 1000 +
5279+ write_timeout_usec_ / 1000 );
5280+ setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
5281+ sizeof (timeout));
52735282#else
5274- timeval tv;
5275- tv.tv_sec = static_cast <long >(read_timeout_sec_);
5276- tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec_);
5277- setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof (tv));
5283+ timeval tv;
5284+ tv.tv_sec = static_cast <long >(read_timeout_sec_);
5285+ tv.tv_usec = static_cast <decltype (tv.tv_usec )>(read_timeout_usec_);
5286+ setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof (tv));
52785287#endif
5279- }
5288+ }
52805289
52815290#if __cplusplus > 201703L
52825291 task_queue->enqueue ([=, this ]() { process_and_close_socket (sock); });
0 commit comments