Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
atimin committed Aug 6, 2024
1 parent 78deaf1 commit b090090
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/reduct/internal/http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ using httplib::DataSink;

constexpr size_t kMaxChunkSize = 512'000;

Result<IHttpClient::Headers> NormalizeHeaders(httplib::Result res) {
IHttpClient::Headers response_headers;
for (auto& [k, v] : res->headers) {
std::string lowcase_header = k;
std::transform(k.begin(), k.end(), lowcase_header.begin(), [](auto ch) { return tolower(ch); });
response_headers[lowcase_header] = v;
}

return {std::move(response_headers), Error::kOk};
}

class HttpClient : public IHttpClient {
public:
explicit HttpClient(std::string_view url, const HttpOptions& options)
Expand Down Expand Up @@ -121,7 +132,7 @@ class HttpClient : public IHttpClient {
return {{}, std::move(err)};
}

return NormilizeHeaders(std::move(res));
return NormalizeHeaders(std::move(res));
}

Error Put(std::string_view path, std::string_view body, std::string_view mime) const noexcept override {
Expand All @@ -139,7 +150,7 @@ class HttpClient : public IHttpClient {
return {{}, std::move(err)};
}

return NormilizeHeaders(std::move(res));
return NormalizeHeaders(std::move(res));
}

Error Delete(std::string_view path) const noexcept override {
Expand Down Expand Up @@ -213,15 +224,4 @@ bool IsCompatible(std::string_view min, std::string_view version) {
return min_version[0] == current_version[0] && min_version[1] <= current_version[1];
}

Result<IHttpClient::Headers> NormilizeHeaders(httplib::Result res) {
IHttpClient::Headers response_headers;
for (auto& [k, v] : res->headers) {
std::string lowcase_header = k;
std::transform(k.begin(), k.end(), lowcase_header.begin(), [](auto ch) { return tolower(ch); });
response_headers[lowcase_header] = v;
}

return {std::move(response_headers), Error::kOk};
}

} // namespace reduct::internal

0 comments on commit b090090

Please sign in to comment.