mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 06:26:02 -07:00
Move, not copy, Logger and Handler functors (#1576)
* Explicitly #include <utility> for use of std::move * Move not copy Logger arg from Client to ClientImpl * Move not copy, set_error_handler Handler to lambda * Remove null statement in non-empty if/else block I guess it was a relic from a time before the other statement was added. --------- Co-authored-by: Daniel Boles <daniel.boles@voltalis.com>
This commit is contained in:
parent
27c0e1186c
commit
698a1e51ec
1 changed files with 5 additions and 4 deletions
|
@ -223,6 +223,7 @@ using socket_t = int;
|
|||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
#ifdef _WIN32
|
||||
|
@ -5242,7 +5243,7 @@ inline Server &Server::set_error_handler(HandlerWithResponse handler) {
|
|||
}
|
||||
|
||||
inline Server &Server::set_error_handler(Handler handler) {
|
||||
error_handler_ = [handler](const Request &req, Response &res) {
|
||||
error_handler_ = [handler = std::move(handler)](const Request &req, Response &res) {
|
||||
handler(req, res);
|
||||
return HandlerResponse::Handled;
|
||||
};
|
||||
|
@ -5272,7 +5273,6 @@ inline Server &Server::set_logger(Logger logger) {
|
|||
inline Server &
|
||||
Server::set_expect_100_continue_handler(Expect100ContinueHandler handler) {
|
||||
expect_100_continue_handler_ = std::move(handler);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -6801,7 +6801,6 @@ inline std::unique_ptr<Response> ClientImpl::send_with_content_provider(
|
|||
req.set_header("Transfer-Encoding", "chunked");
|
||||
} else {
|
||||
req.body.assign(body, content_length);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8750,7 +8749,9 @@ inline void Client::enable_server_certificate_verification(bool enabled) {
|
|||
}
|
||||
#endif
|
||||
|
||||
inline void Client::set_logger(Logger logger) { cli_->set_logger(logger); }
|
||||
inline void Client::set_logger(Logger logger) {
|
||||
cli_->set_logger(std::move(logger));
|
||||
}
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
inline void Client::set_ca_cert_path(const std::string &ca_cert_file_path,
|
||||
|
|
Loading…
Reference in a new issue