Use move semantics instead of copy for functions (#692)

* Use move semantics instead of copy for functions

In some cases, a few more copies could be prevented by changing function definitions to accept parameters by const-ref, rather than by value, but I didn't want to change public signatures.

* Fix two use-after-move errors
This commit is contained in:
Andrew Gasparovic 2020-10-11 16:00:36 -07:00 committed by GitHub
parent d37bc0fb4d
commit fffbf1a669
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

152
httplib.h
View file

@ -317,14 +317,17 @@ public:
ContentReceiver receiver)>; ContentReceiver receiver)>;
ContentReader(Reader reader, MultipartReader multipart_reader) ContentReader(Reader reader, MultipartReader multipart_reader)
: reader_(reader), multipart_reader_(multipart_reader) {} : reader_(std::move(reader)),
multipart_reader_(std::move(multipart_reader)) {}
bool operator()(MultipartContentHeader header, bool operator()(MultipartContentHeader header,
ContentReceiver receiver) const { ContentReceiver receiver) const {
return multipart_reader_(header, receiver); return multipart_reader_(std::move(header), std::move(receiver));
} }
bool operator()(ContentReceiver receiver) const { return reader_(receiver); } bool operator()(ContentReceiver receiver) const {
return reader_(std::move(receiver));
}
Reader reader_; Reader reader_;
MultipartReader multipart_reader_; MultipartReader multipart_reader_;
@ -475,7 +478,7 @@ public:
void enqueue(std::function<void()> fn) override { void enqueue(std::function<void()> fn) override {
std::unique_lock<std::mutex> lock(mutex_); std::unique_lock<std::mutex> lock(mutex_);
jobs_.push_back(fn); jobs_.push_back(std::move(fn));
cond_.notify_one(); cond_.notify_one();
} }
@ -1951,7 +1954,7 @@ inline socket_t create_client_socket(const char *host, int port,
time_t timeout_sec, time_t timeout_usec, time_t timeout_sec, time_t timeout_usec,
const std::string &intf, Error &error) { const std::string &intf, Error &error) {
auto sock = create_socket( auto sock = create_socket(
host, port, 0, tcp_nodelay, socket_options, host, port, 0, tcp_nodelay, std::move(socket_options),
[&](socket_t sock, struct addrinfo &ai) -> bool { [&](socket_t sock, struct addrinfo &ai) -> bool {
if (!intf.empty()) { if (!intf.empty()) {
#ifdef USE_IF2IP #ifdef USE_IF2IP
@ -2607,7 +2610,7 @@ bool prepare_content_receiver(T &x, int &status, ContentReceiver receiver,
buf, n, buf, n,
[&](const char *buf, size_t n) { return receiver(buf, n); }); [&](const char *buf, size_t n) { return receiver(buf, n); });
}; };
return callback(out); return callback(std::move(out));
} else { } else {
status = 500; status = 500;
return false; return false;
@ -2618,7 +2621,7 @@ bool prepare_content_receiver(T &x, int &status, ContentReceiver receiver,
ContentReceiver out = [&](const char *buf, size_t n) { ContentReceiver out = [&](const char *buf, size_t n) {
return receiver(buf, n); return receiver(buf, n);
}; };
return callback(out); return callback(std::move(out));
} }
template <typename T> template <typename T>
@ -2626,7 +2629,7 @@ bool read_content(Stream &strm, T &x, size_t payload_max_length, int &status,
Progress progress, ContentReceiver receiver, Progress progress, ContentReceiver receiver,
bool decompress) { bool decompress) {
return prepare_content_receiver( return prepare_content_receiver(
x, status, receiver, decompress, [&](const ContentReceiver &out) { x, status, std::move(receiver), decompress, [&](const ContentReceiver &out) {
auto ret = true; auto ret = true;
auto exceed_payload_max_length = false; auto exceed_payload_max_length = false;
@ -2641,7 +2644,7 @@ bool read_content(Stream &strm, T &x, size_t payload_max_length, int &status,
skip_content_with_length(strm, len); skip_content_with_length(strm, len);
ret = false; ret = false;
} else if (len > 0) { } else if (len > 0) {
ret = read_content_with_length(strm, len, progress, out); ret = read_content_with_length(strm, len, std::move(progress), out);
} }
} }
@ -3463,7 +3466,7 @@ inline std::pair<std::string, std::string> make_range_header(Ranges ranges) {
if (r.second != -1) { field += std::to_string(r.second); } if (r.second != -1) { field += std::to_string(r.second); }
i++; i++;
} }
return std::make_pair("Range", field); return std::make_pair("Range", std::move(field));
} }
inline std::pair<std::string, std::string> inline std::pair<std::string, std::string>
@ -3472,7 +3475,7 @@ make_basic_authentication_header(const std::string &username,
bool is_proxy = false) { bool is_proxy = false) {
auto field = "Basic " + detail::base64_encode(username + ":" + password); auto field = "Basic " + detail::base64_encode(username + ":" + password);
auto key = is_proxy ? "Proxy-Authorization" : "Authorization"; auto key = is_proxy ? "Proxy-Authorization" : "Authorization";
return std::make_pair(key, field); return std::make_pair(key, std::move(field));
} }
inline std::pair<std::string, std::string> inline std::pair<std::string, std::string>
@ -3480,7 +3483,7 @@ make_bearer_token_authentication_header(const std::string &token,
bool is_proxy = false) { bool is_proxy = false) {
auto field = "Bearer " + token; auto field = "Bearer " + token;
auto key = is_proxy ? "Proxy-Authorization" : "Authorization"; auto key = is_proxy ? "Proxy-Authorization" : "Authorization";
return std::make_pair(key, field); return std::make_pair(key, std::move(field));
} }
// Request implementation // Request implementation
@ -3773,60 +3776,66 @@ inline Server::Server()
inline Server::~Server() {} inline Server::~Server() {}
inline Server &Server::Get(const char *pattern, Handler handler) { inline Server &Server::Get(const char *pattern, Handler handler) {
get_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); get_handlers_.push_back(std::make_pair(std::regex(pattern),
std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Post(const char *pattern, Handler handler) { inline Server &Server::Post(const char *pattern, Handler handler) {
post_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); post_handlers_.push_back(std::make_pair(std::regex(pattern),
std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Post(const char *pattern, inline Server &Server::Post(const char *pattern,
HandlerWithContentReader handler) { HandlerWithContentReader handler) {
post_handlers_for_content_reader_.push_back( post_handlers_for_content_reader_.push_back(
std::make_pair(std::regex(pattern), handler)); std::make_pair(std::regex(pattern), std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Put(const char *pattern, Handler handler) { inline Server &Server::Put(const char *pattern, Handler handler) {
put_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); put_handlers_.push_back(std::make_pair(std::regex(pattern),
std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Put(const char *pattern, inline Server &Server::Put(const char *pattern,
HandlerWithContentReader handler) { HandlerWithContentReader handler) {
put_handlers_for_content_reader_.push_back( put_handlers_for_content_reader_.push_back(
std::make_pair(std::regex(pattern), handler)); std::make_pair(std::regex(pattern), std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Patch(const char *pattern, Handler handler) { inline Server &Server::Patch(const char *pattern, Handler handler) {
patch_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); patch_handlers_.push_back(std::make_pair(std::regex(pattern),
std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Patch(const char *pattern, inline Server &Server::Patch(const char *pattern,
HandlerWithContentReader handler) { HandlerWithContentReader handler) {
patch_handlers_for_content_reader_.push_back( patch_handlers_for_content_reader_.push_back(
std::make_pair(std::regex(pattern), handler)); std::make_pair(std::regex(pattern), std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Delete(const char *pattern, Handler handler) { inline Server &Server::Delete(const char *pattern, Handler handler) {
delete_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); delete_handlers_.push_back(std::make_pair(std::regex(pattern),
std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Delete(const char *pattern, inline Server &Server::Delete(const char *pattern,
HandlerWithContentReader handler) { HandlerWithContentReader handler) {
delete_handlers_for_content_reader_.push_back( delete_handlers_for_content_reader_.push_back(
std::make_pair(std::regex(pattern), handler)); std::make_pair(std::regex(pattern), std::move(handler)));
return *this; return *this;
} }
inline Server &Server::Options(const char *pattern, Handler handler) { inline Server &Server::Options(const char *pattern, Handler handler) {
options_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); options_handlers_.push_back(std::make_pair(std::regex(pattern),
std::move(handler)));
return *this; return *this;
} }
@ -3872,7 +3881,7 @@ inline void Server::set_error_handler(Handler handler) {
inline void Server::set_tcp_nodelay(bool on) { tcp_nodelay_ = on; } inline void Server::set_tcp_nodelay(bool on) { tcp_nodelay_ = on; }
inline void Server::set_socket_options(SocketOptions socket_options) { inline void Server::set_socket_options(SocketOptions socket_options) {
socket_options_ = socket_options; socket_options_ = std::move(socket_options);
} }
inline void Server::set_logger(Logger logger) { logger_ = std::move(logger); } inline void Server::set_logger(Logger logger) { logger_ = std::move(logger); }
@ -4210,8 +4219,9 @@ inline bool Server::read_content_with_content_receiver(
Stream &strm, Request &req, Response &res, ContentReceiver receiver, Stream &strm, Request &req, Response &res, ContentReceiver receiver,
MultipartContentHeader multipart_header, MultipartContentHeader multipart_header,
ContentReceiver multipart_receiver) { ContentReceiver multipart_receiver) {
return read_content_core(strm, req, res, receiver, multipart_header, return read_content_core(strm, req, res, std::move(receiver),
multipart_receiver); std::move(multipart_header),
std::move(multipart_receiver));
} }
inline bool Server::read_content_core(Stream &strm, Request &req, Response &res, inline bool Server::read_content_core(Stream &strm, Request &req, Response &res,
@ -4242,11 +4252,11 @@ inline bool Server::read_content_core(Stream &strm, Request &req, Response &res,
} }
return true; return true;
*/ */
return multipart_form_data_parser.parse(buf, n, multipart_receiver, return multipart_form_data_parser.parse(buf, n, std::move(multipart_receiver),
mulitpart_header); std::move(mulitpart_header));
}; };
} else { } else {
out = receiver; out = std::move(receiver);
} }
if (req.method == "DELETE" && !req.has_header("Content-Length")) { if (req.method == "DELETE" && !req.has_header("Content-Length")) {
@ -4302,7 +4312,7 @@ inline socket_t
Server::create_server_socket(const char *host, int port, int socket_flags, Server::create_server_socket(const char *host, int port, int socket_flags,
SocketOptions socket_options) const { SocketOptions socket_options) const {
return detail::create_socket( return detail::create_socket(
host, port, socket_flags, tcp_nodelay_, socket_options, host, port, socket_flags, tcp_nodelay_, std::move(socket_options),
[](socket_t sock, struct addrinfo &ai) -> bool { [](socket_t sock, struct addrinfo &ai) -> bool {
if (::bind(sock, ai.ai_addr, static_cast<socklen_t>(ai.ai_addrlen))) { if (::bind(sock, ai.ai_addr, static_cast<socklen_t>(ai.ai_addrlen))) {
return false; return false;
@ -4404,32 +4414,38 @@ inline bool Server::routing(Request &req, Response &res, Stream &strm) {
{ {
ContentReader reader( ContentReader reader(
[&](ContentReceiver receiver) { [&](ContentReceiver receiver) {
return read_content_with_content_receiver(strm, req, res, receiver, return read_content_with_content_receiver(strm, req, res,
std::move(receiver),
nullptr, nullptr); nullptr, nullptr);
}, },
[&](MultipartContentHeader header, ContentReceiver receiver) { [&](MultipartContentHeader header, ContentReceiver receiver) {
return read_content_with_content_receiver(strm, req, res, nullptr, return read_content_with_content_receiver(strm, req, res, nullptr,
header, receiver); std::move(header),
std::move(receiver));
}); });
if (req.method == "POST") { if (req.method == "POST") {
if (dispatch_request_for_content_reader( if (dispatch_request_for_content_reader(
req, res, reader, post_handlers_for_content_reader_)) { req, res, std::move(reader),
post_handlers_for_content_reader_)) {
return true; return true;
} }
} else if (req.method == "PUT") { } else if (req.method == "PUT") {
if (dispatch_request_for_content_reader( if (dispatch_request_for_content_reader(
req, res, reader, put_handlers_for_content_reader_)) { req, res, std::move(reader),
put_handlers_for_content_reader_)) {
return true; return true;
} }
} else if (req.method == "PATCH") { } else if (req.method == "PATCH") {
if (dispatch_request_for_content_reader( if (dispatch_request_for_content_reader(
req, res, reader, patch_handlers_for_content_reader_)) { req, res, std::move(reader),
patch_handlers_for_content_reader_)) {
return true; return true;
} }
} else if (req.method == "DELETE") { } else if (req.method == "DELETE") {
if (dispatch_request_for_content_reader( if (dispatch_request_for_content_reader(
req, res, reader, delete_handlers_for_content_reader_)) { req, res, std::move(reader),
delete_handlers_for_content_reader_)) {
return true; return true;
} }
} }
@ -5048,7 +5064,7 @@ inline std::shared_ptr<Response> ClientImpl::send_with_content_provider(
{ {
if (content_provider) { if (content_provider) {
req.content_length = content_length; req.content_length = content_length;
req.content_provider = content_provider; req.content_provider = std::move(content_provider);
} else { } else {
req.body = body; req.body = body;
} }
@ -5102,7 +5118,8 @@ inline bool ClientImpl::process_request(Stream &strm, const Request &req,
int dummy_status; int dummy_status;
if (!detail::read_content(strm, res, (std::numeric_limits<size_t>::max)(), if (!detail::read_content(strm, res, (std::numeric_limits<size_t>::max)(),
dummy_status, progress, out, decompress_)) { dummy_status, std::move(progress), std::move(out),
decompress_)) {
if (error_ != Error::Canceled) { error_ = Error::Read; } if (error_ != Error::Canceled) { error_ = Error::Read; }
return false; return false;
} }
@ -5124,7 +5141,8 @@ ClientImpl::process_socket(Socket &socket,
std::function<bool(Stream &strm)> callback) { std::function<bool(Stream &strm)> callback) {
return detail::process_client_socket(socket.sock, read_timeout_sec_, return detail::process_client_socket(socket.sock, read_timeout_sec_,
read_timeout_usec_, write_timeout_sec_, read_timeout_usec_, write_timeout_sec_,
write_timeout_usec_, callback); write_timeout_usec_,
std::move(callback));
} }
inline bool ClientImpl::is_ssl() const { return false; } inline bool ClientImpl::is_ssl() const { return false; }
@ -5182,23 +5200,23 @@ inline Result ClientImpl::Get(const char *path, const Headers &headers,
inline Result ClientImpl::Get(const char *path, inline Result ClientImpl::Get(const char *path,
ResponseHandler response_handler, ResponseHandler response_handler,
ContentReceiver content_receiver) { ContentReceiver content_receiver) {
return Get(path, Headers(), std::move(response_handler), content_receiver, return Get(path, Headers(), std::move(response_handler),
nullptr); std::move(content_receiver), nullptr);
} }
inline Result ClientImpl::Get(const char *path, const Headers &headers, inline Result ClientImpl::Get(const char *path, const Headers &headers,
ResponseHandler response_handler, ResponseHandler response_handler,
ContentReceiver content_receiver) { ContentReceiver content_receiver) {
return Get(path, headers, std::move(response_handler), content_receiver, return Get(path, headers, std::move(response_handler),
nullptr); std::move(content_receiver), nullptr);
} }
inline Result ClientImpl::Get(const char *path, inline Result ClientImpl::Get(const char *path,
ResponseHandler response_handler, ResponseHandler response_handler,
ContentReceiver content_receiver, ContentReceiver content_receiver,
Progress progress) { Progress progress) {
return Get(path, Headers(), std::move(response_handler), content_receiver, return Get(path, Headers(), std::move(response_handler),
progress); std::move(content_receiver), std::move(progress));
} }
inline Result ClientImpl::Get(const char *path, const Headers &headers, inline Result ClientImpl::Get(const char *path, const Headers &headers,
@ -5259,7 +5277,8 @@ inline Result ClientImpl::Post(const char *path, const Params &params) {
inline Result ClientImpl::Post(const char *path, size_t content_length, inline Result ClientImpl::Post(const char *path, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return Post(path, Headers(), content_length, content_provider, content_type); return Post(path, Headers(), content_length, std::move(content_provider),
content_type);
} }
inline Result ClientImpl::Post(const char *path, const Headers &headers, inline Result ClientImpl::Post(const char *path, const Headers &headers,
@ -5267,7 +5286,8 @@ inline Result ClientImpl::Post(const char *path, const Headers &headers,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
auto ret = send_with_content_provider("POST", path, headers, std::string(), auto ret = send_with_content_provider("POST", path, headers, std::string(),
content_length, content_provider, content_length,
std::move(content_provider),
content_type); content_type);
return Result{ret, get_last_error()}; return Result{ret, get_last_error()};
} }
@ -5340,7 +5360,8 @@ inline Result ClientImpl::Put(const char *path, const Headers &headers,
inline Result ClientImpl::Put(const char *path, size_t content_length, inline Result ClientImpl::Put(const char *path, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return Put(path, Headers(), content_length, content_provider, content_type); return Put(path, Headers(), content_length, std::move(content_provider),
content_type);
} }
inline Result ClientImpl::Put(const char *path, const Headers &headers, inline Result ClientImpl::Put(const char *path, const Headers &headers,
@ -5348,7 +5369,8 @@ inline Result ClientImpl::Put(const char *path, const Headers &headers,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
auto ret = send_with_content_provider("PUT", path, headers, std::string(), auto ret = send_with_content_provider("PUT", path, headers, std::string(),
content_length, content_provider, content_length,
std::move(content_provider),
content_type); content_type);
return Result{ret, get_last_error()}; return Result{ret, get_last_error()};
} }
@ -5379,7 +5401,8 @@ inline Result ClientImpl::Patch(const char *path, const Headers &headers,
inline Result ClientImpl::Patch(const char *path, size_t content_length, inline Result ClientImpl::Patch(const char *path, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return Patch(path, Headers(), content_length, content_provider, content_type); return Patch(path, Headers(), content_length, std::move(content_provider),
content_type);
} }
inline Result ClientImpl::Patch(const char *path, const Headers &headers, inline Result ClientImpl::Patch(const char *path, const Headers &headers,
@ -5387,7 +5410,8 @@ inline Result ClientImpl::Patch(const char *path, const Headers &headers,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
auto ret = send_with_content_provider("PATCH", path, headers, std::string(), auto ret = send_with_content_provider("PATCH", path, headers, std::string(),
content_length, content_provider, content_length,
std::move(content_provider),
content_type); content_type);
return Result{ret, get_last_error()}; return Result{ret, get_last_error()};
} }
@ -5502,7 +5526,7 @@ inline void ClientImpl::set_default_headers(Headers headers) {
inline void ClientImpl::set_tcp_nodelay(bool on) { tcp_nodelay_ = on; } inline void ClientImpl::set_tcp_nodelay(bool on) { tcp_nodelay_ = on; }
inline void ClientImpl::set_socket_options(SocketOptions socket_options) { inline void ClientImpl::set_socket_options(SocketOptions socket_options) {
socket_options_ = socket_options; socket_options_ = std::move(socket_options);
} }
inline void ClientImpl::set_compress(bool on) { compress_ = on; } inline void ClientImpl::set_compress(bool on) { compress_ = on; }
@ -6047,7 +6071,7 @@ SSLClient::process_socket(Socket &socket,
assert(socket.ssl); assert(socket.ssl);
return detail::process_client_socket_ssl( return detail::process_client_socket_ssl(
socket.ssl, socket.sock, read_timeout_sec_, read_timeout_usec_, socket.ssl, socket.sock, read_timeout_sec_, read_timeout_usec_,
write_timeout_sec_, write_timeout_usec_, callback); write_timeout_sec_, write_timeout_usec_, std::move(callback));
} }
inline bool SSLClient::is_ssl() const { return true; } inline bool SSLClient::is_ssl() const { return true; }
@ -6244,11 +6268,11 @@ inline Result Client::Get(const char *path, const Headers &headers) {
return cli_->Get(path, headers); return cli_->Get(path, headers);
} }
inline Result Client::Get(const char *path, Progress progress) { inline Result Client::Get(const char *path, Progress progress) {
return cli_->Get(path, progress); return cli_->Get(path, std::move(progress));
} }
inline Result Client::Get(const char *path, const Headers &headers, inline Result Client::Get(const char *path, const Headers &headers,
Progress progress) { Progress progress) {
return cli_->Get(path, headers, progress); return cli_->Get(path, headers, std::move(progress));
} }
inline Result Client::Get(const char *path, ContentReceiver content_receiver) { inline Result Client::Get(const char *path, ContentReceiver content_receiver) {
return cli_->Get(path, std::move(content_receiver)); return cli_->Get(path, std::move(content_receiver));
@ -6285,7 +6309,8 @@ inline Result Client::Get(const char *path, ResponseHandler response_handler,
inline Result Client::Get(const char *path, const Headers &headers, inline Result Client::Get(const char *path, const Headers &headers,
ResponseHandler response_handler, ResponseHandler response_handler,
ContentReceiver content_receiver, Progress progress) { ContentReceiver content_receiver, Progress progress) {
return cli_->Get(path, headers, response_handler, content_receiver, progress); return cli_->Get(path, headers, std::move(response_handler),
std::move(content_receiver), std::move(progress));
} }
inline Result Client::Head(const char *path) { return cli_->Head(path); } inline Result Client::Head(const char *path) { return cli_->Head(path); }
@ -6305,13 +6330,14 @@ inline Result Client::Post(const char *path, const Headers &headers,
inline Result Client::Post(const char *path, size_t content_length, inline Result Client::Post(const char *path, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return cli_->Post(path, content_length, content_provider, content_type); return cli_->Post(path, content_length, std::move(content_provider),
content_type);
} }
inline Result Client::Post(const char *path, const Headers &headers, inline Result Client::Post(const char *path, const Headers &headers,
size_t content_length, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return cli_->Post(path, headers, content_length, content_provider, return cli_->Post(path, headers, content_length, std::move(content_provider),
content_type); content_type);
} }
inline Result Client::Post(const char *path, const Params &params) { inline Result Client::Post(const char *path, const Params &params) {
@ -6346,13 +6372,14 @@ inline Result Client::Put(const char *path, const Headers &headers,
inline Result Client::Put(const char *path, size_t content_length, inline Result Client::Put(const char *path, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return cli_->Put(path, content_length, content_provider, content_type); return cli_->Put(path, content_length, std::move(content_provider),
content_type);
} }
inline Result Client::Put(const char *path, const Headers &headers, inline Result Client::Put(const char *path, const Headers &headers,
size_t content_length, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return cli_->Put(path, headers, content_length, content_provider, return cli_->Put(path, headers, content_length, std::move(content_provider),
content_type); content_type);
} }
inline Result Client::Put(const char *path, const Params &params) { inline Result Client::Put(const char *path, const Params &params) {
@ -6373,13 +6400,14 @@ inline Result Client::Patch(const char *path, const Headers &headers,
inline Result Client::Patch(const char *path, size_t content_length, inline Result Client::Patch(const char *path, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return cli_->Patch(path, content_length, content_provider, content_type); return cli_->Patch(path, content_length, std::move(content_provider),
content_type);
} }
inline Result Client::Patch(const char *path, const Headers &headers, inline Result Client::Patch(const char *path, const Headers &headers,
size_t content_length, size_t content_length,
ContentProvider content_provider, ContentProvider content_provider,
const char *content_type) { const char *content_type) {
return cli_->Patch(path, headers, content_length, content_provider, return cli_->Patch(path, headers, content_length, std::move(content_provider),
content_type); content_type);
} }
inline Result Client::Delete(const char *path) { return cli_->Delete(path); } inline Result Client::Delete(const char *path) { return cli_->Delete(path); }
@ -6414,7 +6442,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_tcp_nodelay(bool on) { cli_->set_tcp_nodelay(on); }
inline void Client::set_socket_options(SocketOptions socket_options) { inline void Client::set_socket_options(SocketOptions socket_options) {
cli_->set_socket_options(socket_options); cli_->set_socket_options(std::move(socket_options));
} }
inline void Client::set_connection_timeout(time_t sec, time_t usec) { inline void Client::set_connection_timeout(time_t sec, time_t usec) {