diff --git a/server/core/test/test_utils.cc b/server/core/test/test_utils.cc index e0de656ad..a4c22d808 100644 --- a/server/core/test/test_utils.cc +++ b/server/core/test/test_utils.cc @@ -170,10 +170,25 @@ int test_checksums() return 0; } +void test_http() +{ + auto res = mxs::http::get("https://mariadb.com/"); + std::cout << "https://mariadb.com/ responded with: " << res.code << std::endl; + if (res.code == 200) + { + if (res.headers.count("Date")) + { + std::cout << "The date is: " << res.headers["Date"] << std::endl; + } + } +} + int main(int argc, char* argv[]) { int rv = 0; + test_http(); // Just to see that it works + rv += test_trim(); rv += test_trim_leading(); rv += test_trim_trailing(); diff --git a/server/core/utils.cc b/server/core/utils.cc index 4d77fa8f7..c5ab185ae 100644 --- a/server/core/utils.cc +++ b/server/core/utils.cc @@ -1248,6 +1248,9 @@ Result get(const std::string& url) char errbuf[CURL_ERROR_SIZE + 1] = ""; CURL* curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); // For connection phase + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); // For data transfer phase curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res.raw_body);