|
|
@@ -668,9 +668,18 @@ public:
|
|
|
|
|
|
Server &set_keep_alive_max_count(size_t count);
|
|
|
Server &set_keep_alive_timeout(time_t sec);
|
|
|
+
|
|
|
Server &set_read_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ Server &set_read_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
+
|
|
|
Server &set_write_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ Server &set_write_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
+
|
|
|
Server &set_idle_interval(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ Server &set_idle_interval(const std::chrono::duration<Rep, Period> &duration);
|
|
|
|
|
|
Server &set_payload_max_length(size_t length);
|
|
|
|
|
|
@@ -966,8 +975,16 @@ public:
|
|
|
void set_socket_options(SocketOptions socket_options);
|
|
|
|
|
|
void set_connection_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ void set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
+
|
|
|
void set_read_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ void set_read_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
+
|
|
|
void set_write_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ void set_write_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
|
|
|
void set_basic_auth(const char *username, const char *password);
|
|
|
void set_bearer_token_auth(const char *token);
|
|
|
@@ -1268,8 +1285,16 @@ public:
|
|
|
void set_socket_options(SocketOptions socket_options);
|
|
|
|
|
|
void set_connection_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ void set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
+
|
|
|
void set_read_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ void set_read_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
+
|
|
|
void set_write_timeout(time_t sec, time_t usec = 0);
|
|
|
+ template <class Rep, class Period>
|
|
|
+ void set_write_timeout(const std::chrono::duration<Rep, Period> &duration);
|
|
|
|
|
|
void set_basic_auth(const char *username, const char *password);
|
|
|
void set_bearer_token_auth(const char *token);
|
|
|
@@ -3804,6 +3829,15 @@ private:
|
|
|
ContentProviderWithoutLength content_provider_;
|
|
|
};
|
|
|
|
|
|
+template <typename T, typename U>
|
|
|
+inline void duration_to_sec_and_usec(const T &duration, U callback) {
|
|
|
+ auto sec = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
|
|
|
+ auto usec = std::chrono::duration_cast<std::chrono::microseconds>(
|
|
|
+ duration - std::chrono::seconds(sec))
|
|
|
+ .count();
|
|
|
+ callback(sec, usec);
|
|
|
+}
|
|
|
+
|
|
|
} // namespace detail
|
|
|
|
|
|
// Header utilities
|
|
|
@@ -4381,6 +4415,15 @@ inline Server &Server::set_read_timeout(time_t sec, time_t usec) {
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+template <class Rep, class Period>
|
|
|
+inline Server &Server::set_read_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
|
|
+ set_read_timeout(sec, usec);
|
|
|
+ });
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
inline Server &Server::set_write_timeout(time_t sec, time_t usec) {
|
|
|
write_timeout_sec_ = sec;
|
|
|
write_timeout_usec_ = usec;
|
|
|
@@ -4388,6 +4431,15 @@ inline Server &Server::set_write_timeout(time_t sec, time_t usec) {
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+template <class Rep, class Period>
|
|
|
+inline Server &Server::set_write_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
|
|
+ set_write_timeout(sec, usec);
|
|
|
+ });
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
inline Server &Server::set_idle_interval(time_t sec, time_t usec) {
|
|
|
idle_interval_sec_ = sec;
|
|
|
idle_interval_usec_ = usec;
|
|
|
@@ -4395,6 +4447,15 @@ inline Server &Server::set_idle_interval(time_t sec, time_t usec) {
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+template <class Rep, class Period>
|
|
|
+inline Server &Server::set_idle_interval(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
|
|
+ set_idle_interval(sec, usec);
|
|
|
+ });
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
inline Server &Server::set_payload_max_length(size_t length) {
|
|
|
payload_max_length_ = length;
|
|
|
|
|
|
@@ -6273,16 +6334,40 @@ inline void ClientImpl::set_connection_timeout(time_t sec, time_t usec) {
|
|
|
connection_timeout_usec_ = usec;
|
|
|
}
|
|
|
|
|
|
+template <class Rep, class Period>
|
|
|
+inline void ClientImpl::set_connection_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
|
|
+ set_connection_timeout(sec, usec);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
inline void ClientImpl::set_read_timeout(time_t sec, time_t usec) {
|
|
|
read_timeout_sec_ = sec;
|
|
|
read_timeout_usec_ = usec;
|
|
|
}
|
|
|
|
|
|
+template <class Rep, class Period>
|
|
|
+inline void ClientImpl::set_read_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ detail::duration_to_sec_and_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) {
|
|
|
write_timeout_sec_ = sec;
|
|
|
write_timeout_usec_ = usec;
|
|
|
}
|
|
|
|
|
|
+template <class Rep, class Period>
|
|
|
+inline void ClientImpl::set_write_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
|
|
|
+ set_write_timeout(sec, usec);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
inline void ClientImpl::set_basic_auth(const char *username,
|
|
|
const char *password) {
|
|
|
basic_auth_username_ = username;
|
|
|
@@ -7372,6 +7457,7 @@ inline void Client::set_default_headers(Headers headers) {
|
|
|
}
|
|
|
|
|
|
inline void Client::set_tcp_nodelay(bool on) { cli_->set_tcp_nodelay(on); }
|
|
|
+
|
|
|
inline void Client::set_socket_options(SocketOptions socket_options) {
|
|
|
cli_->set_socket_options(std::move(socket_options));
|
|
|
}
|
|
|
@@ -7379,13 +7465,33 @@ inline void Client::set_socket_options(SocketOptions socket_options) {
|
|
|
inline void Client::set_connection_timeout(time_t sec, time_t usec) {
|
|
|
cli_->set_connection_timeout(sec, usec);
|
|
|
}
|
|
|
+
|
|
|
+template <class Rep, class Period>
|
|
|
+inline void Client::set_connection_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ cli_->set_connection_timeout(duration);
|
|
|
+}
|
|
|
+
|
|
|
inline void Client::set_read_timeout(time_t sec, time_t usec) {
|
|
|
cli_->set_read_timeout(sec, usec);
|
|
|
}
|
|
|
+
|
|
|
+template <class Rep, class Period>
|
|
|
+inline void Client::set_read_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ cli_->set_read_timeout(duration);
|
|
|
+}
|
|
|
+
|
|
|
inline void Client::set_write_timeout(time_t sec, time_t usec) {
|
|
|
cli_->set_write_timeout(sec, usec);
|
|
|
}
|
|
|
|
|
|
+template <class Rep, class Period>
|
|
|
+inline void Client::set_write_timeout(
|
|
|
+ const std::chrono::duration<Rep, Period> &duration) {
|
|
|
+ cli_->set_write_timeout(duration);
|
|
|
+}
|
|
|
+
|
|
|
inline void Client::set_basic_auth(const char *username, const char *password) {
|
|
|
cli_->set_basic_auth(username, password);
|
|
|
}
|