| 1146 | Aws::Client::ClientConfiguration* mutable_config() { return &client_config_; } |
| 1147 | |
| 1148 | Result<std::shared_ptr<S3ClientHolder>> BuildClient( |
| 1149 | std::optional<io::IOContext> io_context = std::nullopt) { |
| 1150 | credentials_provider_ = options_.credentials_provider; |
| 1151 | if (!options_.region.empty()) { |
| 1152 | client_config_.region = ToAwsString(options_.region); |
| 1153 | } |
| 1154 | if (options_.request_timeout > 0) { |
| 1155 | // Use ceil() to avoid setting it to 0 as that probably means no timeout. |
| 1156 | client_config_.requestTimeoutMs = |
| 1157 | static_cast<long>(ceil(options_.request_timeout * 1000)); // NOLINT runtime/int |
| 1158 | } |
| 1159 | if (options_.connect_timeout > 0) { |
| 1160 | client_config_.connectTimeoutMs = |
| 1161 | static_cast<long>(ceil(options_.connect_timeout * 1000)); // NOLINT runtime/int |
| 1162 | } |
| 1163 | |
| 1164 | client_config_.endpointOverride = ToAwsString(options_.endpoint_override); |
| 1165 | if (options_.scheme == "http") { |
| 1166 | client_config_.scheme = Aws::Http::Scheme::HTTP; |
| 1167 | } else if (options_.scheme == "https") { |
| 1168 | client_config_.scheme = Aws::Http::Scheme::HTTPS; |
| 1169 | } else { |
| 1170 | return Status::Invalid("Invalid S3 connection scheme '", options_.scheme, "'"); |
| 1171 | } |
| 1172 | if (options_.retry_strategy) { |
| 1173 | client_config_.retryStrategy = |
| 1174 | std::make_shared<WrappedRetryStrategy>(options_.retry_strategy); |
| 1175 | } else { |
| 1176 | client_config_.retryStrategy = std::make_shared<ConnectRetryStrategy>(); |
| 1177 | } |
| 1178 | if (!options_.tls_ca_file_path.empty()) { |
| 1179 | client_config_.caFile = ToAwsString(options_.tls_ca_file_path); |
| 1180 | } else if (!internal::global_options.tls_ca_file_path.empty()) { |
| 1181 | client_config_.caFile = ToAwsString(internal::global_options.tls_ca_file_path); |
| 1182 | } |
| 1183 | if (!options_.tls_ca_dir_path.empty()) { |
| 1184 | client_config_.caPath = ToAwsString(options_.tls_ca_dir_path); |
| 1185 | } else if (!internal::global_options.tls_ca_dir_path.empty()) { |
| 1186 | client_config_.caPath = ToAwsString(internal::global_options.tls_ca_dir_path); |
| 1187 | } |
| 1188 | client_config_.verifySSL = options_.tls_verify_certificates; |
| 1189 | |
| 1190 | // Set proxy options if provided |
| 1191 | if (!options_.proxy_options.scheme.empty()) { |
| 1192 | if (options_.proxy_options.scheme == "http") { |
| 1193 | client_config_.proxyScheme = Aws::Http::Scheme::HTTP; |
| 1194 | } else if (options_.proxy_options.scheme == "https") { |
| 1195 | client_config_.proxyScheme = Aws::Http::Scheme::HTTPS; |
| 1196 | } else { |
| 1197 | return Status::Invalid("Invalid proxy connection scheme '", |
| 1198 | options_.proxy_options.scheme, "'"); |
| 1199 | } |
| 1200 | } |
| 1201 | if (!options_.proxy_options.host.empty()) { |
| 1202 | client_config_.proxyHost = ToAwsString(options_.proxy_options.host); |
| 1203 | } |
| 1204 | if (options_.proxy_options.port != -1) { |
| 1205 | client_config_.proxyPort = options_.proxy_options.port; |
no test coverage detected