Skip to content

Commit

Permalink
CURLINFO_RESPONSE_CODE uses long (not int)
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Feb 7, 2025
1 parent 5b7ccbd commit 58400cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cpp/include/kvikio/defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class defaults {
*
* @return The list of HTTP status codes to retry.
*/
[[nodiscard]] static std::vector<int> http_status_codes();
[[nodiscard]] static std::vector<int> const& http_status_codes();

/**
* @brief Reset the list of HTTP status codes to retry.
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/defaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,8 @@ defaults::defaults()
}
// Determine the default value of `http_status_codes`
{
const std::vector<int> env =
_http_status_codes =
getenv_or("KVIKIO_HTTP_STATUS_CODES", std::vector<int>{429, 500, 502, 503, 504});
_http_status_codes = env;
}
}

Expand Down Expand Up @@ -256,7 +255,7 @@ void defaults::max_attempts_reset(std::size_t attempts)
instance()->_max_attempts = attempts;
}

std::vector<int> defaults::http_status_codes() { return instance()->_http_status_codes; }
std::vector<int> const& defaults::http_status_codes() { return instance()->_http_status_codes; }

void defaults::http_status_codes_reset(std::vector<int> status_codes)
{
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/shim/libcurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ CURL* CurlHandle::handle() noexcept { return _handle.get(); }
void CurlHandle::perform()
{
CURLcode err;
int http_code = 0;
int attempt_count = 1;
int baseDelay = 100; // milliseconds
std::size_t max_attempts = kvikio::defaults::max_attempts();
std::vector<int> http_status_codes = kvikio::defaults::http_status_codes();
long http_code = 0;
int attempt_count = 1;
int baseDelay = 100; // milliseconds
std::size_t max_attempts = kvikio::defaults::max_attempts();
std::vector<int> const& http_status_codes = kvikio::defaults::http_status_codes();

while (attempt_count <= max_attempts) {
std::stringstream ss;
Expand Down

0 comments on commit 58400cb

Please sign in to comment.