From e2813d9d4d4a3cb7ee5b1902cf44a0b9529c921e Mon Sep 17 00:00:00 2001 From: yhirose Date: Mon, 23 Oct 2023 16:43:12 -0400 Subject: [PATCH] Code cleanup. (Removed unnecessary `.c_str()` calls) --- httplib.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/httplib.h b/httplib.h index feeb130..e400a2b 100644 --- a/httplib.h +++ b/httplib.h @@ -3326,7 +3326,7 @@ find_content_type(const std::string &path, auto ext = file_extension(path); auto it = user_data.find(ext); - if (it != user_data.end()) { return it->second.c_str(); } + if (it != user_data.end()) { return it->second; } using udl::operator""_t; @@ -6082,7 +6082,7 @@ inline bool Server::handle_file_request(const Request &req, Response &res, if (detail::is_file(path)) { for (const auto &kv : entry.headers) { - res.set_header(kv.first.c_str(), kv.second); + res.set_header(kv.first, kv.second); } auto mm = std::make_shared(path.c_str()); @@ -6992,7 +6992,7 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) { } else { if (next_scheme == "https") { #ifdef CPPHTTPLIB_OPENSSL_SUPPORT - SSLClient cli(next_host.c_str(), next_port); + SSLClient cli(next_host, next_port); cli.copy_settings(*this); if (ca_cert_store_) { cli.set_ca_cert_store(ca_cert_store_); } return detail::redirect(cli, req, res, path, location, error); @@ -7000,7 +7000,7 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) { return false; #endif } else { - ClientImpl cli(next_host.c_str(), next_port); + ClientImpl cli(next_host, next_port); cli.copy_settings(*this); return detail::redirect(cli, req, res, path, location, error); } @@ -7478,7 +7478,7 @@ inline Result ClientImpl::Get(const std::string &path, const Params ¶ms, if (params.empty()) { return Get(path, headers); } std::string path_with_query = append_query_params(path, params); - return Get(path_with_query.c_str(), headers, progress); + return Get(path_with_query, headers, progress); } inline Result ClientImpl::Get(const std::string &path, const Params ¶ms, @@ -7498,7 +7498,7 @@ inline Result ClientImpl::Get(const std::string &path, const Params ¶ms, } std::string path_with_query = append_query_params(path, params); - return Get(path_with_query.c_str(), headers, response_handler, + return Get(path_with_query, headers, response_handler, content_receiver, progress); } @@ -7601,7 +7601,7 @@ inline Result ClientImpl::Post(const std::string &path, const Headers &headers, const auto &content_type = detail::serialize_multipart_formdata_get_content_type(boundary); const auto &body = detail::serialize_multipart_formdata(items, boundary); - return Post(path, headers, body, content_type.c_str()); + return Post(path, headers, body, content_type); } inline Result ClientImpl::Post(const std::string &path, const Headers &headers, @@ -7614,7 +7614,7 @@ inline Result ClientImpl::Post(const std::string &path, const Headers &headers, const auto &content_type = detail::serialize_multipart_formdata_get_content_type(boundary); const auto &body = detail::serialize_multipart_formdata(items, boundary); - return Post(path, headers, body, content_type.c_str()); + return Post(path, headers, body, content_type); } inline Result