@@ -2013,7 +2013,7 @@ inline bool from_hex_to_i(const std::string &s, size_t i, size_t cnt,
20132013 val = 0 ;
20142014 for (; cnt; i++, cnt--) {
20152015 if (!s[i]) { return false ; }
2016- int v = 0 ;
2016+ auto v = 0 ;
20172017 if (is_hex (s[i], v)) {
20182018 val = val * 16 + v;
20192019 } else {
@@ -2074,8 +2074,8 @@ inline std::string base64_encode(const std::string &in) {
20742074 std::string out;
20752075 out.reserve (in.size ());
20762076
2077- int val = 0 ;
2078- int valb = -6 ;
2077+ auto val = 0 ;
2078+ auto valb = -6 ;
20792079
20802080 for (auto c : in) {
20812081 val = (val << 8 ) + static_cast <uint8_t >(c);
@@ -2206,7 +2206,7 @@ inline std::string decode_url(const std::string &s,
22062206 for (size_t i = 0 ; i < s.size (); i++) {
22072207 if (s[i] == ' %' && i + 1 < s.size ()) {
22082208 if (s[i + 1 ] == ' u' ) {
2209- int val = 0 ;
2209+ auto val = 0 ;
22102210 if (from_hex_to_i (s, i + 2 , 4 , val)) {
22112211 // 4 digits Unicode codes
22122212 char buff[4 ];
@@ -2217,7 +2217,7 @@ inline std::string decode_url(const std::string &s,
22172217 result += s[i];
22182218 }
22192219 } else {
2220- int val = 0 ;
2220+ auto val = 0 ;
22212221 if (from_hex_to_i (s, i + 1 , 2 , val)) {
22222222 // 2 digits hex codes
22232223 result += static_cast <char >(val);
@@ -2468,7 +2468,7 @@ inline Error wait_until_socket_is_ready(socket_t sock, time_t sec,
24682468 if (poll_res == 0 ) { return Error::ConnectionTimeout; }
24692469
24702470 if (poll_res > 0 && pfd_read.revents & (POLLIN | POLLOUT)) {
2471- int error = 0 ;
2471+ auto error = 0 ;
24722472 socklen_t len = sizeof (error);
24732473 auto res = getsockopt (sock, SOL_SOCKET, SO_ERROR,
24742474 reinterpret_cast <char *>(&error), &len);
@@ -2500,7 +2500,7 @@ inline Error wait_until_socket_is_ready(socket_t sock, time_t sec,
25002500 if (ret == 0 ) { return Error::ConnectionTimeout; }
25012501
25022502 if (ret > 0 && (FD_ISSET (sock, &fdsr) || FD_ISSET (sock, &fdsw))) {
2503- int error = 0 ;
2503+ auto error = 0 ;
25042504 socklen_t len = sizeof (error);
25052505 auto res = getsockopt (sock, SOL_SOCKET, SO_ERROR,
25062506 reinterpret_cast <char *>(&error), &len);
@@ -2745,7 +2745,7 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
27452745#endif
27462746
27472747 if (tcp_nodelay) {
2748- int yes = 1 ;
2748+ auto yes = 1 ;
27492749#ifdef _WIN32
27502750 setsockopt (sock, IPPROTO_TCP, TCP_NODELAY,
27512751 reinterpret_cast <const char *>(&yes), sizeof (yes));
@@ -2758,7 +2758,7 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
27582758 if (socket_options) { socket_options (sock); }
27592759
27602760 if (rp->ai_family == AF_INET6) {
2761- int no = 0 ;
2761+ auto no = 0 ;
27622762#ifdef _WIN32
27632763 setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY,
27642764 reinterpret_cast <const char *>(&no), sizeof (no));
@@ -3240,7 +3240,7 @@ inline bool gzip_compressor::compress(const char *data, size_t data_length,
32403240 data += strm_.avail_in ;
32413241
32423242 auto flush = (last && data_length == 0 ) ? Z_FINISH : Z_NO_FLUSH;
3243- int ret = Z_OK;
3243+ auto ret = Z_OK;
32443244
32453245 std::array<char , CPPHTTPLIB_COMPRESSION_BUFSIZ> buff{};
32463246 do {
@@ -3284,7 +3284,7 @@ inline bool gzip_decompressor::decompress(const char *data, size_t data_length,
32843284 Callback callback) {
32853285 assert (is_valid_);
32863286
3287- int ret = Z_OK;
3287+ auto ret = Z_OK;
32883288
32893289 do {
32903290 constexpr size_t max_avail_in =
@@ -4587,7 +4587,7 @@ inline bool retrieve_root_certs_from_keychain(CFObjectPtr<CFArrayRef> &certs) {
45874587
45884588inline bool add_certs_to_x509_store (CFArrayRef certs, X509_STORE *store) {
45894589 auto result = false ;
4590- for (int i = 0 ; i < CFArrayGetCount (certs); ++i) {
4590+ for (auto i = 0 ; i < CFArrayGetCount (certs); ++i) {
45914591 const auto cert = reinterpret_cast <const __SecCertificate *>(
45924592 CFArrayGetValueAtIndex (certs, i));
45934593
@@ -4805,7 +4805,7 @@ inline void hosted_at(const std::string &hostname,
48054805 const auto &addr =
48064806 *reinterpret_cast <struct sockaddr_storage *>(rp->ai_addr );
48074807 std::string ip;
4808- int dummy = -1 ;
4808+ auto dummy = -1 ;
48094809 if (detail::get_ip_and_port (addr, sizeof (struct sockaddr_storage ), ip,
48104810 dummy)) {
48114811 addrs.push_back (ip);
@@ -7697,7 +7697,7 @@ bool ssl_connect_or_accept_nonblocking(socket_t sock, SSL *ssl,
76977697 U ssl_connect_or_accept,
76987698 time_t timeout_sec,
76997699 time_t timeout_usec) {
7700- int res = 0 ;
7700+ auto res = 0 ;
77017701 while ((res = ssl_connect_or_accept (ssl)) != 1 ) {
77027702 auto err = SSL_get_error (ssl, res);
77037703 switch (err) {
@@ -7778,7 +7778,7 @@ inline ssize_t SSLSocketStream::read(char *ptr, size_t size) {
77787778 auto ret = SSL_read (ssl_, ptr, static_cast <int >(size));
77797779 if (ret < 0 ) {
77807780 auto err = SSL_get_error (ssl_, ret);
7781- int n = 1000 ;
7781+ auto n = 1000 ;
77827782#ifdef _WIN32
77837783 while (--n >= 0 && (err == SSL_ERROR_WANT_READ ||
77847784 (err == SSL_ERROR_SYSCALL &&
@@ -7811,7 +7811,7 @@ inline ssize_t SSLSocketStream::write(const char *ptr, size_t size) {
78117811 auto ret = SSL_write (ssl_, ptr, static_cast <int >(handle_size));
78127812 if (ret < 0 ) {
78137813 auto err = SSL_get_error (ssl_, ret);
7814- int n = 1000 ;
7814+ auto n = 1000 ;
78157815#ifdef _WIN32
78167816 while (--n >= 0 && (err == SSL_ERROR_WANT_WRITE ||
78177817 (err == SSL_ERROR_SYSCALL &&
0 commit comments