Skip to content

Commit

Permalink
Code cleanup. (Removed unnecessary .c_str() calls)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Oct 23, 2023
1 parent 20a7f08 commit e2813d9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<detail::mmap>(path.c_str());
Expand Down Expand Up @@ -6992,15 +6992,15 @@ 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);
#else
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);
}
Expand Down Expand Up @@ -7478,7 +7478,7 @@ inline Result ClientImpl::Get(const std::string &path, const Params &params,
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 &params,
Expand All @@ -7498,7 +7498,7 @@ inline Result ClientImpl::Get(const std::string &path, const Params &params,
}

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);
}

Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit e2813d9

Please sign in to comment.