diff --git a/src/lib/io/QueryParams.cpp b/src/lib/io/QueryParams.cpp index a547c7609..1387a200f 100644 --- a/src/lib/io/QueryParams.cpp +++ b/src/lib/io/QueryParams.cpp @@ -1,15 +1,17 @@ #include "QueryParams.h" -#include -#include namespace bts::io { std::string QueryParams::to_string() const { std::string rv; - auto query_param_strs = ranges::transform_view( - *this, [](const auto &qp) { return qp.first + "=" + qp.second; }); - rv.append(fmt::format( - "{}", fmt::join(query_param_strs.begin(), query_param_strs.end(), "&"))); + auto it = begin(); + if (it == end()) { + return ""; + } + rv.append(it->first + "=" + it->second); + while (++it != end()) { + rv.append("&" + it->first + "=" + it->second); + } return rv; } diff --git a/src/lib/io/URL.cpp b/src/lib/io/URL.cpp index 6b8660d6a..5fb868324 100644 --- a/src/lib/io/URL.cpp +++ b/src/lib/io/URL.cpp @@ -1,15 +1,11 @@ #include "URL.h" #include "lib/api/io/URL.pb.h" -#include + #include -#include -#include #include namespace bts::io { -// URL:: URL(const api::io::URL &url) : protocol_(url.protocol()), -// host_(url.host()), port_(url.port()), path_(url.path()) {} URL::URL(const bts::api::io::URL &url) : protocol_(url.protocol()), host_(url.host()), port_(url.port()), path_(url.path()) { @@ -76,13 +72,7 @@ std::string URL::to_string() const { } if (!query_params_.empty()) { rv.append("?"); - auto query_param_strs = - ranges::transform_view(query_params_, [](const auto &qp) { - return qp.first + "=" + qp.second; - }); - rv.append(fmt::format( - "{}", - fmt::join(query_param_strs.begin(), query_param_strs.end(), "&"))); + rv.append(query_params_.to_string()); } return rv; } diff --git a/src/lib/io/http/HTTPHeaders.cpp b/src/lib/io/http/HTTPHeaders.cpp index 9bffd8418..8c26cf97f 100644 --- a/src/lib/io/http/HTTPHeaders.cpp +++ b/src/lib/io/http/HTTPHeaders.cpp @@ -1,39 +1,35 @@ #include "HTTPHeaders.h" #include "lib/utils/StringSplitter.h" -#include -#include + #include -#include -#include namespace bts::io::http { HTTPHeaders::HTTPHeaders(const std::string &str) { auto item_strs = utils::StringSplitter::split(str, "\n"); - auto items = ranges::transform_view( - item_strs, - [](const std::string &item_str) -> std::pair { - auto kv = utils::StringSplitter::split(item_str, ":"); - if (kv.empty()) { - return std::make_pair("", ""); - } - if (kv.size() == 1) { - return std::make_pair(kv[0], std::string("")); - } - return std::make_pair(kv[0], kv[1]); - }); - for (auto p : items) { - try_emplace(p.first, p.second); + for (const auto &item_str : item_strs) { + auto kv = utils::StringSplitter::split(item_str, ":"); + if (kv.empty()) { + try_emplace("", ""); + continue; + } + if (kv.size() == 1) { + try_emplace(kv[0], ""); + continue; + } + try_emplace(kv[0], kv[1]); } } std::string HTTPHeaders::to_string() const { - std::string rv; - auto query_param_strs = ranges::transform_view( - *this, [](const auto &qp) { return qp.first + ": " + qp.second; }); - rv.append(fmt::format( - "{}", - fmt::join(query_param_strs.begin(), query_param_strs.end(), "\n"))); + auto it = begin(); + if (it == end()) { + return ""; + } + std::string rv{it->first + ": " + it->second}; + while (++it != end()) { + rv.append("\n" + it->first + ": " + it->second); + } return rv; }