Skip to content

Commit

Permalink
Added https support (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
falling-springs authored Nov 27, 2024
1 parent d3a3dee commit 4790bc7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/http_client_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace duckdb {

// Helper function to parse URL and setup client
static std::pair<duckdb_httplib_openssl::Client, std::string> 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) {
Expand All @@ -40,8 +40,15 @@ static std::pair<duckdb_httplib_openssl::Client, std::string> 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

Expand Down

0 comments on commit 4790bc7

Please sign in to comment.