| 1086 | Aws::Client::ClientConfiguration* mutable_config() { return &client_config_; } |
| 1087 | |
| 1088 | Result<std::shared_ptr<S3ClientHolder>> BuildClient( |
| 1089 | std::optional<io::IOContext> io_context = std::nullopt) { |
| 1090 | credentials_provider_ = options_.credentials_provider; |
| 1091 | if (!options_.region.empty()) { |
| 1092 | client_config_.region = ToAwsString(options_.region); |
| 1093 | } |
| 1094 | if (options_.request_timeout > 0) { |
| 1095 | // Use ceil() to avoid setting it to 0 as that probably means no timeout. |
| 1096 | client_config_.requestTimeoutMs = |
| 1097 | static_cast<long>(ceil(options_.request_timeout * 1000)); // NOLINT runtime/int |
| 1098 | } |
| 1099 | if (options_.connect_timeout > 0) { |
| 1100 | client_config_.connectTimeoutMs = |
| 1101 | static_cast<long>(ceil(options_.connect_timeout * 1000)); // NOLINT runtime/int |
| 1102 | } |
| 1103 | |
| 1104 | client_config_.endpointOverride = ToAwsString(options_.endpoint_override); |
| 1105 | if (options_.scheme == "http") { |
| 1106 | client_config_.scheme = Aws::Http::Scheme::HTTP; |
| 1107 | } else if (options_.scheme == "https") { |
| 1108 | client_config_.scheme = Aws::Http::Scheme::HTTPS; |
| 1109 | } else { |
| 1110 | return Status::Invalid("Invalid S3 connection scheme '", options_.scheme, "'"); |
| 1111 | } |
| 1112 | if (options_.retry_strategy) { |
| 1113 | client_config_.retryStrategy = |
| 1114 | std::make_shared<WrappedRetryStrategy>(options_.retry_strategy); |
| 1115 | } else { |
| 1116 | client_config_.retryStrategy = std::make_shared<ConnectRetryStrategy>(); |
| 1117 | } |
| 1118 | if (!options_.tls_ca_file_path.empty()) { |
| 1119 | client_config_.caFile = ToAwsString(options_.tls_ca_file_path); |
| 1120 | } else if (!internal::global_options.tls_ca_file_path.empty()) { |
| 1121 | client_config_.caFile = ToAwsString(internal::global_options.tls_ca_file_path); |
| 1122 | } |
| 1123 | if (!options_.tls_ca_dir_path.empty()) { |
| 1124 | client_config_.caPath = ToAwsString(options_.tls_ca_dir_path); |
| 1125 | } else if (!internal::global_options.tls_ca_dir_path.empty()) { |
| 1126 | client_config_.caPath = ToAwsString(internal::global_options.tls_ca_dir_path); |
| 1127 | } |
| 1128 | client_config_.verifySSL = options_.tls_verify_certificates; |
| 1129 | |
| 1130 | // Set proxy options if provided |
| 1131 | if (!options_.proxy_options.scheme.empty()) { |
| 1132 | if (options_.proxy_options.scheme == "http") { |
| 1133 | client_config_.proxyScheme = Aws::Http::Scheme::HTTP; |
| 1134 | } else if (options_.proxy_options.scheme == "https") { |
| 1135 | client_config_.proxyScheme = Aws::Http::Scheme::HTTPS; |
| 1136 | } else { |
| 1137 | return Status::Invalid("Invalid proxy connection scheme '", |
| 1138 | options_.proxy_options.scheme, "'"); |
| 1139 | } |
| 1140 | } |
| 1141 | if (!options_.proxy_options.host.empty()) { |
| 1142 | client_config_.proxyHost = ToAwsString(options_.proxy_options.host); |
| 1143 | } |
| 1144 | if (options_.proxy_options.port != -1) { |
| 1145 | client_config_.proxyPort = options_.proxy_options.port; |
no test coverage detected