From 4790bc7255e18dfb4db1a383214ff49c0719919b Mon Sep 17 00:00:00 2001 From: falling-springs <129777850+falling-springs@users.noreply.github.com> Date: Wed, 27 Nov 2024 05:13:33 -0500 Subject: [PATCH] Added https support (#14) --- src/http_client_extension.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/http_client_extension.cpp b/src/http_client_extension.cpp index 1ddb68a..3453b67 100644 --- a/src/http_client_extension.cpp +++ b/src/http_client_extension.cpp @@ -23,7 +23,7 @@ namespace duckdb { // Helper function to parse URL and setup client static std::pair SetupHttpClient(const std::string &url) { - std::string scheme, domain, path; + std::string scheme, domain, path, client_url; size_t pos = url.find("://"); std::string mod_url = url; if (pos != std::string::npos) { @@ -40,8 +40,15 @@ static std::pair SetupHttpClient(co path = "/"; } + // Construct client url with https if specified + if (scheme == "https") { + client_url = scheme + "://" + domain; + } else { + client_url = domain; + } + // Create client and set a reasonable timeout (e.g., 10 seconds) - duckdb_httplib_openssl::Client client(domain.c_str()); + duckdb_httplib_openssl::Client client(client_url); client.set_read_timeout(10, 0); // 10 seconds client.set_follow_location(true); // Follow redirects