Code formatting
This commit is contained in:
parent
14c6d526b4
commit
d122ff3ca8
74
httplib.h
74
httplib.h
@ -200,11 +200,11 @@ using socket_t = int;
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
@ -976,7 +976,8 @@ public:
|
|||||||
|
|
||||||
void set_connection_timeout(time_t sec, time_t usec = 0);
|
void set_connection_timeout(time_t sec, time_t usec = 0);
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
void set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
|
void
|
||||||
|
set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
|
||||||
|
|
||||||
void set_read_timeout(time_t sec, time_t usec = 0);
|
void set_read_timeout(time_t sec, time_t usec = 0);
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
@ -1286,7 +1287,8 @@ public:
|
|||||||
|
|
||||||
void set_connection_timeout(time_t sec, time_t usec = 0);
|
void set_connection_timeout(time_t sec, time_t usec = 0);
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
void set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
|
void
|
||||||
|
set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
|
||||||
|
|
||||||
void set_read_timeout(time_t sec, time_t usec = 0);
|
void set_read_timeout(time_t sec, time_t usec = 0);
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
@ -3200,9 +3202,7 @@ inline void parse_query_text(const std::string &s, Params ¶ms) {
|
|||||||
std::set<std::string> cache;
|
std::set<std::string> cache;
|
||||||
split(s.data(), s.data() + s.size(), '&', [&](const char *b, const char *e) {
|
split(s.data(), s.data() + s.size(), '&', [&](const char *b, const char *e) {
|
||||||
std::string kv(b, e);
|
std::string kv(b, e);
|
||||||
if (cache.find(kv) != cache.end()) {
|
if (cache.find(kv) != cache.end()) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
cache.insert(kv);
|
cache.insert(kv);
|
||||||
|
|
||||||
std::string key;
|
std::string key;
|
||||||
@ -3744,9 +3744,9 @@ inline std::pair<std::string, std::string> make_digest_authentication_header(
|
|||||||
|
|
||||||
string response;
|
string response;
|
||||||
{
|
{
|
||||||
auto H = algo == "SHA-256"
|
auto H = algo == "SHA-256" ? detail::SHA_256
|
||||||
? detail::SHA_256
|
: algo == "SHA-512" ? detail::SHA_512
|
||||||
: algo == "SHA-512" ? detail::SHA_512 : detail::MD5;
|
: detail::MD5;
|
||||||
|
|
||||||
auto A1 = username + ":" + auth.at("realm") + ":" + password;
|
auto A1 = username + ":" + auth.at("realm") + ":" + password;
|
||||||
|
|
||||||
@ -4333,13 +4333,11 @@ inline Server &
|
|||||||
Server::set_file_extension_and_mimetype_mapping(const char *ext,
|
Server::set_file_extension_and_mimetype_mapping(const char *ext,
|
||||||
const char *mime) {
|
const char *mime) {
|
||||||
file_extension_and_mimetype_map_[ext] = mime;
|
file_extension_and_mimetype_map_[ext] = mime;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_file_request_handler(Handler handler) {
|
inline Server &Server::set_file_request_handler(Handler handler) {
|
||||||
file_request_handler_ = std::move(handler);
|
file_request_handler_ = std::move(handler);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4373,7 +4371,6 @@ inline Server &Server::set_post_routing_handler(Handler handler) {
|
|||||||
|
|
||||||
inline Server &Server::set_logger(Logger logger) {
|
inline Server &Server::set_logger(Logger logger) {
|
||||||
logger_ = std::move(logger);
|
logger_ = std::move(logger);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4386,79 +4383,68 @@ Server::set_expect_100_continue_handler(Expect100ContinueHandler handler) {
|
|||||||
|
|
||||||
inline Server &Server::set_tcp_nodelay(bool on) {
|
inline Server &Server::set_tcp_nodelay(bool on) {
|
||||||
tcp_nodelay_ = on;
|
tcp_nodelay_ = on;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_socket_options(SocketOptions socket_options) {
|
inline Server &Server::set_socket_options(SocketOptions socket_options) {
|
||||||
socket_options_ = std::move(socket_options);
|
socket_options_ = std::move(socket_options);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_keep_alive_max_count(size_t count) {
|
inline Server &Server::set_keep_alive_max_count(size_t count) {
|
||||||
keep_alive_max_count_ = count;
|
keep_alive_max_count_ = count;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_keep_alive_timeout(time_t sec) {
|
inline Server &Server::set_keep_alive_timeout(time_t sec) {
|
||||||
keep_alive_timeout_sec_ = sec;
|
keep_alive_timeout_sec_ = sec;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_read_timeout(time_t sec, time_t usec) {
|
inline Server &Server::set_read_timeout(time_t sec, time_t usec) {
|
||||||
read_timeout_sec_ = sec;
|
read_timeout_sec_ = sec;
|
||||||
read_timeout_usec_ = usec;
|
read_timeout_usec_ = usec;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
inline Server &Server::set_read_timeout(
|
inline Server &
|
||||||
const std::chrono::duration<Rep, Period> &duration) {
|
Server::set_read_timeout(const std::chrono::duration<Rep, Period> &duration) {
|
||||||
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
detail::duration_to_sec_and_usec(
|
||||||
set_read_timeout(sec, usec);
|
duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); });
|
||||||
});
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_write_timeout(time_t sec, time_t usec) {
|
inline Server &Server::set_write_timeout(time_t sec, time_t usec) {
|
||||||
write_timeout_sec_ = sec;
|
write_timeout_sec_ = sec;
|
||||||
write_timeout_usec_ = usec;
|
write_timeout_usec_ = usec;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
inline Server &Server::set_write_timeout(
|
inline Server &
|
||||||
const std::chrono::duration<Rep, Period> &duration) {
|
Server::set_write_timeout(const std::chrono::duration<Rep, Period> &duration) {
|
||||||
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
detail::duration_to_sec_and_usec(
|
||||||
set_write_timeout(sec, usec);
|
duration, [&](time_t sec, time_t usec) { set_write_timeout(sec, usec); });
|
||||||
});
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_idle_interval(time_t sec, time_t usec) {
|
inline Server &Server::set_idle_interval(time_t sec, time_t usec) {
|
||||||
idle_interval_sec_ = sec;
|
idle_interval_sec_ = sec;
|
||||||
idle_interval_usec_ = usec;
|
idle_interval_usec_ = usec;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
inline Server &Server::set_idle_interval(
|
inline Server &
|
||||||
const std::chrono::duration<Rep, Period> &duration) {
|
Server::set_idle_interval(const std::chrono::duration<Rep, Period> &duration) {
|
||||||
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
detail::duration_to_sec_and_usec(
|
||||||
set_idle_interval(sec, usec);
|
duration, [&](time_t sec, time_t usec) { set_idle_interval(sec, usec); });
|
||||||
});
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::set_payload_max_length(size_t length) {
|
inline Server &Server::set_payload_max_length(size_t length) {
|
||||||
payload_max_length_ = length;
|
payload_max_length_ = length;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6353,9 +6339,8 @@ inline void ClientImpl::set_read_timeout(time_t sec, time_t usec) {
|
|||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
inline void ClientImpl::set_read_timeout(
|
inline void ClientImpl::set_read_timeout(
|
||||||
const std::chrono::duration<Rep, Period> &duration) {
|
const std::chrono::duration<Rep, Period> &duration) {
|
||||||
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
detail::duration_to_sec_and_usec(
|
||||||
set_read_timeout(sec, usec);
|
duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ClientImpl::set_write_timeout(time_t sec, time_t usec) {
|
inline void ClientImpl::set_write_timeout(time_t sec, time_t usec) {
|
||||||
@ -6366,9 +6351,8 @@ inline void ClientImpl::set_write_timeout(time_t sec, time_t usec) {
|
|||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
inline void ClientImpl::set_write_timeout(
|
inline void ClientImpl::set_write_timeout(
|
||||||
const std::chrono::duration<Rep, Period> &duration) {
|
const std::chrono::duration<Rep, Period> &duration) {
|
||||||
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
detail::duration_to_sec_and_usec(
|
||||||
set_write_timeout(sec, usec);
|
duration, [&](time_t sec, time_t usec) { set_write_timeout(sec, usec); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ClientImpl::set_basic_auth(const char *username,
|
inline void ClientImpl::set_basic_auth(const char *username,
|
||||||
@ -7480,8 +7464,8 @@ inline void Client::set_read_timeout(time_t sec, time_t usec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
inline void Client::set_read_timeout(
|
inline void
|
||||||
const std::chrono::duration<Rep, Period> &duration) {
|
Client::set_read_timeout(const std::chrono::duration<Rep, Period> &duration) {
|
||||||
cli_->set_read_timeout(duration);
|
cli_->set_read_timeout(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7490,8 +7474,8 @@ inline void Client::set_write_timeout(time_t sec, time_t usec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Rep, class Period>
|
template <class Rep, class Period>
|
||||||
inline void Client::set_write_timeout(
|
inline void
|
||||||
const std::chrono::duration<Rep, Period> &duration) {
|
Client::set_write_timeout(const std::chrono::duration<Rep, Period> &duration) {
|
||||||
cli_->set_write_timeout(duration);
|
cli_->set_write_timeout(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user