|
12 | 12 |
|
13 | 13 | namespace duckdb {
|
14 | 14 |
|
| 15 | +static void SetHttpfsClientImplementation(DBConfig &config, const string &value) { |
| 16 | + if (config.http_util && config.http_util->GetName() == "WasmHTTPUtils") { |
| 17 | + if (value == "wasm" || value == "default") { |
| 18 | + // Already handled, do not override |
| 19 | + return; |
| 20 | + } |
| 21 | + throw InvalidInputException("Unsupported option for httpfs_client_implementation, only `wasm` and " |
| 22 | + "`default` are currently supported for duckdb-wasm"); |
| 23 | + } |
| 24 | + if (value == "httplib" || value == "default") { |
| 25 | + if (!config.http_util || config.http_util->GetName() != "HTTPFSUtil") { |
| 26 | + config.http_util = make_shared_ptr<HTTPFSUtil>(); |
| 27 | + } |
| 28 | + return; |
| 29 | + } |
| 30 | + throw InvalidInputException("Unsupported option for httpfs_client_implementation, only `curl`, `httplib` and " |
| 31 | + "`default` are currently supported"); |
| 32 | + } |
| 33 | + |
15 | 34 | static void LoadInternal(DatabaseInstance &instance) {
|
16 | 35 | auto &fs = instance.GetFileSystem();
|
17 | 36 |
|
@@ -64,11 +83,16 @@ static void LoadInternal(DatabaseInstance &instance) {
|
64 | 83 | config.AddExtensionOption("hf_max_per_page", "Debug option to limit number of items returned in list requests",
|
65 | 84 | LogicalType::UBIGINT, Value::UBIGINT(0));
|
66 | 85 |
|
67 |
| - if (config.http_util && config.http_util->GetName() == "WasmHTTPUtils") { |
68 |
| - // Already handled, do not override |
69 |
| - } else { |
70 |
| - config.http_util = make_shared_ptr<HTTPFSUtil>(); |
71 |
| - } |
| 86 | + auto callback_httpfs_client_implementation = [](ClientContext &context, SetScope scope, Value ¶meter) { |
| 87 | + auto &config = DBConfig::GetConfig(context); |
| 88 | + string value = StringValue::Get(parameter); |
| 89 | + SetHttpfsClientImplementation(config, value); |
| 90 | + }; |
| 91 | + |
| 92 | + config.AddExtensionOption("httpfs_client_implementation", "Select which is the HTTPUtil implementation to be used", |
| 93 | + LogicalType::VARCHAR, "default", callback_httpfs_client_implementation); |
| 94 | + |
| 95 | + SetHttpfsClientImplementation(config, "default"); |
72 | 96 |
|
73 | 97 | auto provider = make_uniq<AWSEnvironmentCredentialsProvider>(config);
|
74 | 98 | provider->SetAll();
|
|
0 commit comments