1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #pragma once
7 
8 #include <aws/core/Core_EXPORTS.h>
9 #include <aws/core/http/Scheme.h>
10 #include <aws/core/Region.h>
11 #include <aws/core/utils/memory/stl/AWSString.h>
12 #include <aws/core/http/HttpTypes.h>
13 #include <aws/core/utils/Array.h>
14 #include <aws/crt/Optional.h>
15 #include <memory>
16 
17 namespace Aws
18 {
19     namespace Utils
20     {
21         namespace Threading
22         {
23             class Executor;
24         } // namespace Threading
25 
26         namespace RateLimits
27         {
28             class RateLimiterInterface;
29         } // namespace RateLimits
30     } // namespace Utils
31     namespace Client
32     {
33         class RetryStrategy; // forward declare
34 
35         /**
36          * Sets the behaviors of the underlying HTTP clients handling response with 30x status code.
37          * By default, HTTP clients will always redirect the 30x response automatically, except when
38          * specifying aws-global as the client region, then SDK will handle 30x response and redirect
39          * the request manually.
40          */
41         enum class FollowRedirectsPolicy
42         {
43             DEFAULT,
44             ALWAYS,
45             NEVER
46         };
47 
48         /**
49          * This mutable structure is used to configure any of the AWS clients.
50          * Default values can only be overwritten prior to passing to the client constructors.
51          */
52         struct AWS_CORE_API ClientConfiguration
53         {
54             ClientConfiguration();
55 
56             /**
57              * Create a configuration based on settings in the aws configuration file for the given profile name.
58              * The configuration file location can be set via the environment variable AWS_CONFIG_FILE
59              */
60             ClientConfiguration(const char* profileName);
61 
62             /**
63              * User Agent string user for http calls. This is filled in for you in the constructor. Don't override this unless you have a really good reason.
64              */
65             Aws::String userAgent;
66             /**
67              * Http scheme to use. E.g. Http or Https. Default HTTPS
68              */
69             Aws::Http::Scheme scheme;
70             /**
71              * AWS Region to use in signing requests. Default US_EAST_1
72              */
73             Aws::String region;
74             /**
75              * Use dual stack endpoint in the endpoint calculation. It is your responsibility to verify that the service supports ipv6 in the region you select.
76              */
77             bool useDualStack;
78             /**
79              * Max concurrent tcp connections for a single http client to use. Default 25.
80              */
81             unsigned maxConnections;
82             /**
83              * This is currently only applicable for Curl to set the http request level timeout, including possible dns lookup time, connection establish time, ssl handshake time and actual data transmission time.
84              * the corresponding Curl option is CURLOPT_TIMEOUT_MS
85              * defaults to 0, no http request level timeout.
86              */
87             long httpRequestTimeoutMs;
88             /**
89              * Socket read timeouts for HTTP clients on Windows. Default 3000 ms. This should be more than adequate for most services. However, if you are transfering large amounts of data
90              * or are worried about higher latencies, you should set to something that makes more sense for your use case.
91              * For Curl, it's the low speed time, which contains the time in number milliseconds that transfer speed should be below "lowSpeedLimit" for the library to consider it too slow and abort.
92              * Note that for Curl this config is converted to seconds by rounding down to the nearest whole second except when the value is greater than 0 and less than 1000. In this case it is set to one second. When it's 0, low speed limit check will be disabled.
93              * Note that for Windows when this config is 0, the behavior is not specified by Windows.
94              */
95             long requestTimeoutMs;
96             /**
97              * Socket connect timeout. Default 1000 ms. Unless you are very far away from your the data center you are talking to. 1000ms is more than sufficient.
98              */
99             long connectTimeoutMs;
100             /**
101              * Enable TCP keep-alive. Default true;
102              * No-op for WinHTTP, WinINet and IXMLHTTPRequest2 client.
103              */
104             bool enableTcpKeepAlive;
105             /**
106              * Interval to send a keep-alive packet over the connection. Default 30 seconds. Minimum 15 seconds.
107              * WinHTTP & libcurl support this option. Note that for Curl, this value will be rounded to an integer with second granularity.
108              * No-op for WinINet and IXMLHTTPRequest2 client.
109              */
110             unsigned long tcpKeepAliveIntervalMs;
111             /**
112              * Average transfer speed in bytes per second that the transfer should be below during the request timeout interval for it to be considered too slow and abort.
113              * Default 1 byte/second. Only for CURL client currently.
114              */
115             unsigned long lowSpeedLimit;
116             /**
117              * Strategy to use in case of failed requests. Default is DefaultRetryStrategy (e.g. exponential backoff)
118              */
119             std::shared_ptr<RetryStrategy> retryStrategy;
120             /**
121              * Override the http endpoint used to talk to a service.
122              */
123             Aws::String endpointOverride;
124             /**
125              * If you have users going through a proxy, set the proxy scheme here. Default HTTP
126              */
127             Aws::Http::Scheme proxyScheme;
128             /**
129              * If you have users going through a proxy, set the host here.
130              */
131             Aws::String proxyHost;
132             /**
133              * If you have users going through a proxy, set the port here.
134              */
135             unsigned proxyPort;
136             /**
137              * If you have users going through a proxy, set the username here.
138              */
139             Aws::String proxyUserName;
140             /**
141             * If you have users going through a proxy, set the password here.
142             */
143             Aws::String proxyPassword;
144             /**
145             * SSL Certificate file to use for connecting to an HTTPS proxy.
146             * Used to set CURLOPT_PROXY_SSLCERT in libcurl. Example: client.pem
147             */
148             Aws::String proxySSLCertPath;
149             /**
150             * Type of proxy client SSL certificate.
151             * Used to set CURLOPT_PROXY_SSLCERTTYPE in libcurl. Example: PEM
152             */
153             Aws::String proxySSLCertType;
154             /**
155             * Private key file to use for connecting to an HTTPS proxy.
156             * Used to set CURLOPT_PROXY_SSLKEY in libcurl. Example: key.pem
157             */
158             Aws::String proxySSLKeyPath;
159             /**
160             * Type of private key file used to connect to an HTTPS proxy.
161             * Used to set CURLOPT_PROXY_SSLKEYTYPE in libcurl. Example: PEM
162             */
163             Aws::String proxySSLKeyType;
164             /**
165             * Passphrase to the private key file used to connect to an HTTPS proxy.
166             * Used to set CURLOPT_PROXY_KEYPASSWD in libcurl. Example: password1
167             */
168             Aws::String proxySSLKeyPassword;
169             /**
170             * Calls to hosts in this vector will not use proxy configuration
171             */
172             Aws::Utils::Array<Aws::String> nonProxyHosts;
173             /**
174             * Threading Executor implementation. Default uses std::thread::detach()
175             */
176             std::shared_ptr<Aws::Utils::Threading::Executor> executor;
177             /**
178              * If you need to test and want to get around TLS validation errors, do that here.
179              * you probably shouldn't use this flag in a production scenario.
180              */
181             bool verifySSL;
182             /**
183              * If your Certificate Authority path is different from the default, you can tell
184              * clients that aren't using the default trust store where to find your CA trust store.
185              * If you are on windows or apple, you likely don't want this.
186              */
187             Aws::String caPath;
188             /**
189              * If you certificate file is different from the default, you can tell clients that
190              * aren't using the default trust store where to find your ca file.
191              * If you are on windows or apple, you likely don't want this.
192              */
193              Aws::String caFile;
194             /**
195              * Rate Limiter implementation for outgoing bandwidth. Default is wide-open.
196              */
197             std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> writeRateLimiter;
198             /**
199             * Rate Limiter implementation for incoming bandwidth. Default is wide-open.
200             */
201             std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> readRateLimiter;
202             /**
203              * Override the http implementation the default factory returns.
204              */
205             Aws::Http::TransferLibType httpLibOverride;
206             /**
207              * Sets the behavior how http stack handles 30x redirect codes.
208              */
209             FollowRedirectsPolicy followRedirects;
210 
211             /**
212              * Only works for Curl http client.
213              * Curl will by default add "Expect: 100-Continue" header in a Http request so as to avoid sending http
214              * payload to wire if server respond error immediately after receiving the header.
215              * Set this option to true will tell Curl to send http request header and body together.
216              * This can save one round-trip time and especially useful when the payload is small and network latency is more important.
217              * But be careful when Http request has large payload such S3 PutObject. You don't want to spend long time sending a large payload just getting a error response for server.
218              * The default value will be false.
219              */
220             bool disableExpectHeader;
221 
222             /**
223              * If set to true clock skew will be adjusted after each http attempt, default to true.
224              */
225             bool enableClockSkewAdjustment;
226 
227             /**
228              * Enable host prefix injection.
229              * For services whose endpoint is injectable. e.g. servicediscovery, you can modify the http host's prefix so as to add "data-" prefix for DiscoverInstances request.
230              * Default to true, enabled. You can disable it for testing purpose.
231              */
232             bool enableHostPrefixInjection;
233 
234             /**
235              * Enable endpoint discovery
236              * For some services to dynamically set up their endpoints for different requests.
237              * By default, service clients will decide if endpoint discovery is enabled or not.
238              * If disabled, regional or overridden endpoint will be used instead.
239              * If a request requires endpoint discovery but you disabled it. The request will never succeed.
240              * A boolean value is either true of false, use Optional here to have an instance does not contain a value,
241              * such that SDK will decide the default behavior as stated before, if no value specified.
242              */
243             Aws::Crt::Optional<bool> enableEndpointDiscovery;
244 
245             /**
246              * profileName in config file that will be used by this object to resolve more configurations.
247              */
248             Aws::String profileName;
249         };
250 
251     } // namespace Client
252 } // namespace Aws
253