Skip to content

Commit 06026bb

Browse files
committed
Code formating
1 parent 226388a commit 06026bb

File tree

1 file changed

+41
-45
lines changed

1 file changed

+41
-45
lines changed

httplib.h

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class TaskQueue {
505505
virtual void enqueue(std::function<void()> fn) = 0;
506506
virtual void shutdown() = 0;
507507

508-
virtual void on_idle(){}
508+
virtual void on_idle() {}
509509
};
510510

511511
class ThreadPool : public TaskQueue {
@@ -1663,14 +1663,12 @@ bool process_client_socket(socket_t sock, time_t read_timeout_sec,
16631663
time_t write_timeout_usec,
16641664
std::function<bool(Stream &)> callback);
16651665

1666-
socket_t create_client_socket(const char *host, const char *ip, int port, int address_family,
1667-
bool tcp_nodelay, SocketOptions socket_options,
1668-
time_t connection_timeout_sec,
1669-
time_t connection_timeout_usec,
1670-
time_t read_timeout_sec, time_t read_timeout_usec,
1671-
time_t write_timeout_sec,
1672-
time_t write_timeout_usec,
1673-
const std::string &intf, Error &error);
1666+
socket_t create_client_socket(
1667+
const char *host, const char *ip, int port, int address_family,
1668+
bool tcp_nodelay, SocketOptions socket_options,
1669+
time_t connection_timeout_sec, time_t connection_timeout_usec,
1670+
time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec,
1671+
time_t write_timeout_usec, const std::string &intf, Error &error);
16741672

16751673
const char *get_header_value(const Headers &headers, const char *key,
16761674
size_t id = 0, const char *def = nullptr);
@@ -2209,25 +2207,22 @@ inline ssize_t read_socket(socket_t sock, void *ptr, size_t size, int flags) {
22092207
return handle_EINTR([&]() {
22102208
return recv(sock,
22112209
#ifdef _WIN32
2212-
static_cast<char *>(ptr),
2213-
static_cast<int>(size),
2210+
static_cast<char *>(ptr), static_cast<int>(size),
22142211
#else
2215-
ptr,
2216-
size,
2212+
ptr, size,
22172213
#endif
22182214
flags);
22192215
});
22202216
}
22212217

2222-
inline ssize_t send_socket(socket_t sock, const void *ptr, size_t size, int flags) {
2218+
inline ssize_t send_socket(socket_t sock, const void *ptr, size_t size,
2219+
int flags) {
22232220
return handle_EINTR([&]() {
22242221
return send(sock,
22252222
#ifdef _WIN32
2226-
static_cast<const char *>(ptr),
2227-
static_cast<int>(size),
2223+
static_cast<const char *>(ptr), static_cast<int>(size),
22282224
#else
2229-
ptr,
2230-
size,
2225+
ptr, size,
22312226
#endif
22322227
flags);
22332228
});
@@ -2460,8 +2455,8 @@ inline int shutdown_socket(socket_t sock) {
24602455
}
24612456

24622457
template <typename BindOrConnect>
2463-
socket_t create_socket(const char *host, const char *ip, int port, int address_family,
2464-
int socket_flags, bool tcp_nodelay,
2458+
socket_t create_socket(const char *host, const char *ip, int port,
2459+
int address_family, int socket_flags, bool tcp_nodelay,
24652460
SocketOptions socket_options,
24662461
BindOrConnect bind_or_connect) {
24672462
// Get address info
@@ -2475,16 +2470,15 @@ socket_t create_socket(const char *host, const char *ip, int port, int address_f
24752470
hints.ai_protocol = 0;
24762471

24772472
// Ask getaddrinfo to convert IP in c-string to address
2478-
if(ip[0] != '\0') {
2473+
if (ip[0] != '\0') {
24792474
hints.ai_family = AF_UNSPEC;
24802475
hints.ai_flags = AI_NUMERICHOST;
24812476
}
24822477

24832478
auto service = std::to_string(port);
24842479

2485-
if (ip[0] != '\0' ?
2486-
getaddrinfo(ip, service.c_str(), &hints, &result) :
2487-
getaddrinfo(host, service.c_str(), &hints, &result)) {
2480+
if (ip[0] != '\0' ? getaddrinfo(ip, service.c_str(), &hints, &result)
2481+
: getaddrinfo(host, service.c_str(), &hints, &result)) {
24882482
#if defined __linux__ && !defined __ANDROID__
24892483
res_init();
24902484
#endif
@@ -2619,10 +2613,10 @@ inline std::string if2ip(const std::string &ifn) {
26192613
#endif
26202614

26212615
inline socket_t create_client_socket(
2622-
const char *host, const char *ip, int port, int address_family, bool tcp_nodelay,
2623-
SocketOptions socket_options, time_t connection_timeout_sec,
2624-
time_t connection_timeout_usec, time_t read_timeout_sec,
2625-
time_t read_timeout_usec, time_t write_timeout_sec,
2616+
const char *host, const char *ip, int port, int address_family,
2617+
bool tcp_nodelay, SocketOptions socket_options,
2618+
time_t connection_timeout_sec, time_t connection_timeout_usec,
2619+
time_t read_timeout_sec, time_t read_timeout_usec, time_t write_timeout_sec,
26262620
time_t write_timeout_usec, const std::string &intf, Error &error) {
26272621
auto sock = create_socket(
26282622
host, ip, port, address_family, 0, tcp_nodelay, std::move(socket_options),
@@ -2996,9 +2990,7 @@ inline bool gzip_decompressor::decompress(const char *data, size_t data_length,
29962990

29972991
ret = inflate(&strm_, Z_NO_FLUSH);
29982992

2999-
if (prev_avail_in - strm_.avail_in == 0) {
3000-
return false;
3001-
}
2993+
if (prev_avail_in - strm_.avail_in == 0) { return false; }
30022994

30032995
assert(ret != Z_STREAM_ERROR);
30042996
switch (ret) {
@@ -4442,8 +4434,7 @@ inline SocketStream::SocketStream(socket_t sock, time_t read_timeout_sec,
44424434
: sock_(sock), read_timeout_sec_(read_timeout_sec),
44434435
read_timeout_usec_(read_timeout_usec),
44444436
write_timeout_sec_(write_timeout_sec),
4445-
write_timeout_usec_(write_timeout_usec),
4446-
read_buff_(read_buff_size_, 0) {}
4437+
write_timeout_usec_(write_timeout_usec), read_buff_(read_buff_size_, 0) {}
44474438

44484439
inline SocketStream::~SocketStream() {}
44494440

@@ -4457,9 +4448,11 @@ inline bool SocketStream::is_writable() const {
44574448

44584449
inline ssize_t SocketStream::read(char *ptr, size_t size) {
44594450
#ifdef _WIN32
4460-
size = (std::min)(size, static_cast<size_t>((std::numeric_limits<int>::max)()));
4451+
size =
4452+
(std::min)(size, static_cast<size_t>((std::numeric_limits<int>::max)()));
44614453
#else
4462-
size = (std::min)(size, static_cast<size_t>((std::numeric_limits<ssize_t>::max)()));
4454+
size = (std::min)(size,
4455+
static_cast<size_t>((std::numeric_limits<ssize_t>::max)()));
44634456
#endif
44644457

44654458
if (read_buff_off_ < read_buff_content_size_) {
@@ -4481,7 +4474,8 @@ inline ssize_t SocketStream::read(char *ptr, size_t size) {
44814474
read_buff_content_size_ = 0;
44824475

44834476
if (size < read_buff_size_) {
4484-
auto n = read_socket(sock_, read_buff_.data(), read_buff_size_, CPPHTTPLIB_RECV_FLAGS);
4477+
auto n = read_socket(sock_, read_buff_.data(), read_buff_size_,
4478+
CPPHTTPLIB_RECV_FLAGS);
44854479
if (n <= 0) {
44864480
return n;
44874481
} else if (n <= static_cast<ssize_t>(size)) {
@@ -4502,7 +4496,8 @@ inline ssize_t SocketStream::write(const char *ptr, size_t size) {
45024496
if (!is_writable()) { return -1; }
45034497

45044498
#ifdef _WIN32
4505-
size = (std::min)(size, static_cast<size_t>((std::numeric_limits<int>::max)()));
4499+
size =
4500+
(std::min)(size, static_cast<size_t>((std::numeric_limits<int>::max)()));
45064501
#endif
45074502

45084503
return send_socket(sock_, ptr, size, CPPHTTPLIB_SEND_FLAGS);
@@ -5634,14 +5629,13 @@ inline socket_t ClientImpl::create_client_socket(Error &error) const {
56345629
// Check is custom IP specified for host_
56355630
std::string ip;
56365631
auto it = addr_map_.find(host_);
5637-
if(it != addr_map_.end())
5638-
ip = it->second;
5632+
if (it != addr_map_.end()) ip = it->second;
56395633

56405634
return detail::create_client_socket(
5641-
host_.c_str(), ip.c_str(), port_, address_family_, tcp_nodelay_, socket_options_,
5642-
connection_timeout_sec_, connection_timeout_usec_, read_timeout_sec_,
5643-
read_timeout_usec_, write_timeout_sec_, write_timeout_usec_, interface_,
5644-
error);
5635+
host_.c_str(), ip.c_str(), port_, address_family_, tcp_nodelay_,
5636+
socket_options_, connection_timeout_sec_, connection_timeout_usec_,
5637+
read_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
5638+
write_timeout_usec_, interface_, error);
56455639
}
56465640

56475641
inline bool ClientImpl::create_and_connect_socket(Socket &socket,
@@ -6766,7 +6760,8 @@ inline void ClientImpl::set_follow_location(bool on) { follow_location_ = on; }
67666760

67676761
inline void ClientImpl::set_url_encode(bool on) { url_encode_ = on; }
67686762

6769-
inline void ClientImpl::set_hostname_addr_map(const std::map<std::string, std::string> addr_map) {
6763+
inline void ClientImpl::set_hostname_addr_map(
6764+
const std::map<std::string, std::string> addr_map) {
67706765
addr_map_ = std::move(addr_map);
67716766
}
67726767

@@ -7895,7 +7890,8 @@ inline size_t Client::is_socket_open() const { return cli_->is_socket_open(); }
78957890

78967891
inline void Client::stop() { cli_->stop(); }
78977892

7898-
inline void Client::set_hostname_addr_map(const std::map<std::string, std::string> addr_map) {
7893+
inline void Client::set_hostname_addr_map(
7894+
const std::map<std::string, std::string> addr_map) {
78997895
cli_->set_hostname_addr_map(std::move(addr_map));
79007896
}
79017897

0 commit comments

Comments
 (0)