diff options
author | unril <unril@yandex-team.ru> | 2022-02-10 16:46:05 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:05 +0300 |
commit | 11ae9eca250d0188b7962459cbc6706719e7dca9 (patch) | |
tree | 4b7d6755091980d33210de19b2eb35a401a761ea /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core | |
parent | 9c914f41ba5e9f9365f404e892197553ac23809e (diff) | |
download | ydb-11ae9eca250d0188b7962459cbc6706719e7dca9.tar.gz |
Restoring authorship annotation for <unril@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core')
56 files changed, 2743 insertions, 2743 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h index 8061ee1e25..7e9f6c5bac 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h @@ -13,8 +13,8 @@ #include <aws/core/utils/DateTime.h> #include <aws/core/utils/Array.h> #include <aws/core/utils/threading/ReaderWriterLock.h> -#include <aws/core/utils/crypto/Sha256.h> -#include <aws/core/utils/crypto/Sha256HMAC.h> +#include <aws/core/utils/crypto/Sha256.h> +#include <aws/core/utils/crypto/Sha256HMAC.h> #include <memory> #include <atomic> @@ -30,10 +30,10 @@ namespace Aws namespace Utils { - namespace Event - { - class Message; - } + namespace Event + { + class Message; + } } // namespace Utils namespace Auth @@ -41,8 +41,8 @@ namespace Aws class AWSCredentials; class AWSCredentialsProvider; AWS_CORE_API extern const char SIGV4_SIGNER[]; - AWS_CORE_API extern const char EVENTSTREAM_SIGV4_SIGNER[]; - AWS_CORE_API extern const char SIGNATURE[]; + AWS_CORE_API extern const char EVENTSTREAM_SIGV4_SIGNER[]; + AWS_CORE_API extern const char SIGNATURE[]; AWS_CORE_API extern const char NULL_SIGNER[]; } // namespace Auth @@ -104,20 +104,20 @@ namespace Aws } /** - * Signs a single event message in an event stream. - * The input message buffer is copied and signed. The message's input buffer will be deallocated and a new - * buffer will be assigned. The new buffer encodes the original message with its headers as the payload of - * the new message. The signature of the original message will be added as a header to the new message. - * - * A Hex encoded signature of the previous event (or of the HTTP request headers in case of the first event) - * is provided as the 'priorSignature' parameter. 'priorSignature' will contain the value of the new - * signature after this call returns successfully. - * - * The function returns true if the message is successfully signed. - */ - virtual bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const { return false; } - - /** + * Signs a single event message in an event stream. + * The input message buffer is copied and signed. The message's input buffer will be deallocated and a new + * buffer will be assigned. The new buffer encodes the original message with its headers as the payload of + * the new message. The signature of the original message will be added as a header to the new message. + * + * A Hex encoded signature of the previous event (or of the HTTP request headers in case of the first event) + * is provided as the 'priorSignature' parameter. 'priorSignature' will contain the value of the new + * signature after this call returns successfully. + * + * The function returns true if the message is successfully signed. + */ + virtual bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const { return false; } + + /** * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. * The URI can then be used in a normal HTTP call until expiration. */ @@ -271,12 +271,12 @@ namespace Aws */ bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, long long expirationInSeconds = 0) const override; - Aws::String GetServiceName() const { return m_serviceName; } - Aws::String GetRegion() const { return m_region; } - Aws::String GenerateSignature(const Aws::Auth::AWSCredentials& credentials, - const Aws::String& stringToSign, const Aws::String& simpleDate) const; - bool ShouldSignHeader(const Aws::String& header) const; - + Aws::String GetServiceName() const { return m_serviceName; } + Aws::String GetRegion() const { return m_region; } + Aws::String GenerateSignature(const Aws::Auth::AWSCredentials& credentials, + const Aws::String& stringToSign, const Aws::String& simpleDate) const; + bool ShouldSignHeader(const Aws::String& header) const; + protected: bool m_includeSha256HashHeader; @@ -316,26 +316,26 @@ namespace Aws bool m_urlEscapePath; }; - class AWS_CORE_API AWSAuthEventStreamV4Signer : public AWSAuthSigner - { - public: - AWSAuthEventStreamV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& credentialsProvider, - const char* serviceName, const Aws::String& region); - - const char* GetName() const override { return Aws::Auth::EVENTSTREAM_SIGV4_SIGNER; } - - bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& priorSignature) const override; + class AWS_CORE_API AWSAuthEventStreamV4Signer : public AWSAuthSigner + { + public: + AWSAuthEventStreamV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& credentialsProvider, + const char* serviceName, const Aws::String& region); + const char* GetName() const override { return Aws::Auth::EVENTSTREAM_SIGV4_SIGNER; } + + bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& priorSignature) const override; + bool SignRequest(Aws::Http::HttpRequest& request) const override - { + { return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), true); - } - + } + bool SignRequest(Aws::Http::HttpRequest& request, bool signBody) const override { return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), signBody); } - + bool SignRequest(Aws::Http::HttpRequest& request, const char* region, bool signBody) const override { return SignRequest(request, region, m_serviceName.c_str(), signBody); @@ -343,45 +343,45 @@ namespace Aws bool SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool signBody) const override; - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, long long) const override { return false; } - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, const char*, long long) const override { return false; } - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, const char*, const char*, long long) const override { return false; } - - bool ShouldSignHeader(const Aws::String& header) const; - private: - Utils::ByteBuffer GenerateSignature(const Aws::Auth::AWSCredentials& credentials, + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, long long) const override { return false; } + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, const char*, long long) const override { return false; } + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, const char*, const char*, long long) const override { return false; } + + bool ShouldSignHeader(const Aws::String& header) const; + private: + Utils::ByteBuffer GenerateSignature(const Aws::Auth::AWSCredentials& credentials, const Aws::String& stringToSign, const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; - Utils::ByteBuffer GenerateSignature(const Aws::String& stringToSign, const Aws::Utils::ByteBuffer& key) const; - Aws::String GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, - const Aws::String& canonicalRequestHash, const Aws::String& region, - const Aws::String& serviceName) const; - Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, const Aws::String& simpleDate) const; - Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, - const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; - const Aws::String m_serviceName; - const Aws::String m_region; - mutable Aws::Utils::Crypto::Sha256 m_hash; - mutable Aws::Utils::Crypto::Sha256HMAC m_HMAC; - mutable Utils::Threading::ReaderWriterLock m_derivedKeyLock; - mutable Aws::Utils::ByteBuffer m_derivedKey; - mutable Aws::String m_currentDateStr; - mutable Aws::String m_currentSecretKey; - Aws::Vector<Aws::String> m_unsignedHeaders; - std::shared_ptr<Auth::AWSCredentialsProvider> m_credentialsProvider; - }; - - + Utils::ByteBuffer GenerateSignature(const Aws::String& stringToSign, const Aws::Utils::ByteBuffer& key) const; + Aws::String GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, + const Aws::String& canonicalRequestHash, const Aws::String& region, + const Aws::String& serviceName) const; + Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, const Aws::String& simpleDate) const; + Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, + const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; + const Aws::String m_serviceName; + const Aws::String m_region; + mutable Aws::Utils::Crypto::Sha256 m_hash; + mutable Aws::Utils::Crypto::Sha256HMAC m_HMAC; + mutable Utils::Threading::ReaderWriterLock m_derivedKeyLock; + mutable Aws::Utils::ByteBuffer m_derivedKey; + mutable Aws::String m_currentDateStr; + mutable Aws::String m_currentSecretKey; + Aws::Vector<Aws::String> m_unsignedHeaders; + std::shared_ptr<Auth::AWSCredentialsProvider> m_credentialsProvider; + }; + + /** * A no-op implementation of the AWSAuthSigner interface */ @@ -402,11 +402,11 @@ namespace Aws /** * Do nothing */ - bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const override { return true; } - - /** - * Do nothing - */ + bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const override { return true; } + + /** + * Do nothing + */ bool PresignRequest(Aws::Http::HttpRequest&, long long) const override { return false; } /** diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h index 1c14b955fc..ce51a3c886 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h @@ -2,22 +2,22 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ - - #pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/utils/memory/stl/AWSString.h> + + #pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/DateTime.h> -namespace Aws -{ - namespace Auth - { - /** - * Simple data object around aws credentials - */ - class AWS_CORE_API AWSCredentials - { - public: +namespace Aws +{ + namespace Auth + { + /** + * Simple data object around aws credentials + */ + class AWS_CORE_API AWSCredentials + { + public: /** * Initializes an empty credentials set. * Empty credentials are not expired by default. @@ -26,17 +26,17 @@ namespace Aws AWSCredentials() : m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)()) { } - - /** + + /** * Initializes object with accessKeyId, secretKey. * SessionToken defaults to empty string. * Expiration date is set to "never expire". - */ + */ AWSCredentials(const Aws::String& accessKeyId, const Aws::String& secretKey) : m_accessKeyId(accessKeyId), m_secretKey(secretKey), m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)()) - { - } - + { + } + /** * Initializes object with accessKeyId, secretKey, and sessionToken. * Expiration date is set to "never expire". @@ -45,8 +45,8 @@ namespace Aws m_accessKeyId(accessKeyId), m_secretKey(secretKey), m_sessionToken(sessionToken), m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)()) { } - - /** + + /** * Initializes object with accessKeyId, secretKey, sessionToken and expiration date. */ AWSCredentials(const Aws::String& accessKeyId, const Aws::String& secretKey, const Aws::String& sessionToken, Aws::Utils::DateTime expiration) : @@ -68,40 +68,40 @@ namespace Aws } /** - * If credentials haven't been initialized or been initialized to emtpy values. + * If credentials haven't been initialized or been initialized to emtpy values. * Expiration date does not affect the result of this function. - */ - inline bool IsEmpty() const { return m_accessKeyId.empty() && m_secretKey.empty(); } - + */ + inline bool IsEmpty() const { return m_accessKeyId.empty() && m_secretKey.empty(); } + inline bool IsExpired() const { return m_expiration <= Aws::Utils::DateTime::Now(); } inline bool IsExpiredOrEmpty() const { return IsEmpty() || IsExpired(); } - /** - * Gets the underlying access key credential - */ - inline const Aws::String& GetAWSAccessKeyId() const - { - return m_accessKeyId; - } - - /** - * Gets the underlying secret key credential - */ - inline const Aws::String& GetAWSSecretKey() const - { - return m_secretKey; - } - - /** - * Gets the underlying session token - */ - inline const Aws::String& GetSessionToken() const - { - return m_sessionToken; - } - - /** + /** + * Gets the underlying access key credential + */ + inline const Aws::String& GetAWSAccessKeyId() const + { + return m_accessKeyId; + } + + /** + * Gets the underlying secret key credential + */ + inline const Aws::String& GetAWSSecretKey() const + { + return m_secretKey; + } + + /** + * Gets the underlying session token + */ + inline const Aws::String& GetSessionToken() const + { + return m_sessionToken; + } + + /** * Gets the expiration date of the credential */ inline Aws::Utils::DateTime GetExpiration() const @@ -110,54 +110,54 @@ namespace Aws } /** - * Sets the underlying access key credential. Copies from parameter accessKeyId. - */ - inline void SetAWSAccessKeyId(const Aws::String& accessKeyId) - { - m_accessKeyId = accessKeyId; - } - - /** - * Sets the underlying secret key credential. Copies from parameter secretKey - */ - inline void SetAWSSecretKey(const Aws::String& secretKey) - { - m_secretKey = secretKey; - } - - /** + * Sets the underlying access key credential. Copies from parameter accessKeyId. + */ + inline void SetAWSAccessKeyId(const Aws::String& accessKeyId) + { + m_accessKeyId = accessKeyId; + } + + /** + * Sets the underlying secret key credential. Copies from parameter secretKey + */ + inline void SetAWSSecretKey(const Aws::String& secretKey) + { + m_secretKey = secretKey; + } + + /** * Sets the underlying session token. Copies from parameter sessionToken - */ - inline void SetSessionToken(const Aws::String& sessionToken) - { - m_sessionToken = sessionToken; - } - - - /** + */ + inline void SetSessionToken(const Aws::String& sessionToken) + { + m_sessionToken = sessionToken; + } + + + /** * Sets the underlying access key credential. Copies from parameter accessKeyId. */ - inline void SetAWSAccessKeyId(const char* accessKeyId) - { - m_accessKeyId = accessKeyId; - } - - /** + inline void SetAWSAccessKeyId(const char* accessKeyId) + { + m_accessKeyId = accessKeyId; + } + + /** * Sets the underlying secret key credential. Copies from parameter secretKey */ - inline void SetAWSSecretKey(const char* secretKey) - { - m_secretKey = secretKey; - } - - /** + inline void SetAWSSecretKey(const char* secretKey) + { + m_secretKey = secretKey; + } + + /** * Sets the underlying secret key credential. Copies from parameter secretKey */ - inline void SetSessionToken(const char* sessionToken) - { - m_sessionToken = sessionToken; - } - + inline void SetSessionToken(const char* sessionToken) + { + m_sessionToken = sessionToken; + } + /** * Sets the expiration date of the credential */ @@ -166,11 +166,11 @@ namespace Aws m_expiration = expiration; } - private: - Aws::String m_accessKeyId; - Aws::String m_secretKey; - Aws::String m_sessionToken; + private: + Aws::String m_accessKeyId; + Aws::String m_secretKey; + Aws::String m_sessionToken; Aws::Utils::DateTime m_expiration; - }; - } -} + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h index a3a46964e8..ab98fc5ff1 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h @@ -13,8 +13,8 @@ #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/threading/ReaderWriterLock.h> #include <aws/core/internal/AWSHttpResourceClient.h> -#include <aws/core/auth/AWSCredentials.h> -#include <aws/core/config/AWSProfileConfigLoader.h> +#include <aws/core/auth/AWSCredentials.h> +#include <aws/core/config/AWSProfileConfigLoader.h> #include <aws/core/client/RetryStrategy.h> #include <memory> @@ -185,7 +185,7 @@ namespace Aws void RefreshIfExpired(); Aws::String m_profileToUse; - Aws::Config::AWSConfigFileProfileConfigLoader m_credentialsFileLoader; + Aws::Config::AWSConfigFileProfileConfigLoader m_credentialsFileLoader; long m_loadFrequencyMs; }; @@ -271,46 +271,46 @@ namespace Aws Aws::Auth::AWSCredentials m_credentials; }; - /** - * Process credentials provider that loads credentials by running another command (or program) configured in config file - * The configuration format is as following: - * credential_process = command_path <arguments_list> - * Each time the credentials needs to be refreshed, this command will be executed with configured arguments. - * The default profile name to look up this configuration is "default", same as normal aws credentials configuration and other configurations. - * The expected valid output of the command is a Json doc output to stdout: - * {"Version": 1, "AccessKeyId": "AccessKey123", "SecretAccessKey": "SecretKey321", "SessionToken": "Token123", "Expiration": "1970-01-01T00:00:01Z"} + /** + * Process credentials provider that loads credentials by running another command (or program) configured in config file + * The configuration format is as following: + * credential_process = command_path <arguments_list> + * Each time the credentials needs to be refreshed, this command will be executed with configured arguments. + * The default profile name to look up this configuration is "default", same as normal aws credentials configuration and other configurations. + * The expected valid output of the command is a Json doc output to stdout: + * {"Version": 1, "AccessKeyId": "AccessKey123", "SecretAccessKey": "SecretKey321", "SessionToken": "Token123", "Expiration": "1970-01-01T00:00:01Z"} * The Version key specifies the version of the JSON payload and must be set to 1 for now (as an integer type). - * If the Version key is bumped to 2, SDKs would support both versions of the returned payload. - * Value of Expiration field should be an valid ISO8601 formatted date string as above example. - * The expected error message of the command is a string to output to stderr. - */ - class AWS_CORE_API ProcessCredentialsProvider : public AWSCredentialsProvider - { - public: - /** - * Initializes the provider by checking default profile - */ - ProcessCredentialsProvider(); - - /** - * Initializes the provider by checking specified profile - * @param profile which profile in config file to use. - */ - ProcessCredentialsProvider(const Aws::String& profile); - - /** - * Retrieves the credentials if found, otherwise returns empty credential set. - */ - AWSCredentials GetAWSCredentials() override; - - protected: - void Reload() override; - private: - void RefreshIfExpired(); - - private: - Aws::String m_profileToUse; - Aws::Auth::AWSCredentials m_credentials; - }; + * If the Version key is bumped to 2, SDKs would support both versions of the returned payload. + * Value of Expiration field should be an valid ISO8601 formatted date string as above example. + * The expected error message of the command is a string to output to stderr. + */ + class AWS_CORE_API ProcessCredentialsProvider : public AWSCredentialsProvider + { + public: + /** + * Initializes the provider by checking default profile + */ + ProcessCredentialsProvider(); + + /** + * Initializes the provider by checking specified profile + * @param profile which profile in config file to use. + */ + ProcessCredentialsProvider(const Aws::String& profile); + + /** + * Retrieves the credentials if found, otherwise returns empty credential set. + */ + AWSCredentials GetAWSCredentials() override; + + protected: + void Reload() override; + private: + void RefreshIfExpired(); + + private: + Aws::String m_profileToUse; + Aws::Auth::AWSCredentials m_credentials; + }; } // namespace Auth } // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h index 186206a66e..241bc83e06 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h @@ -15,8 +15,8 @@ #include <memory> #include <atomic> -struct aws_array_list; - +struct aws_array_list; + namespace Aws { namespace Utils @@ -146,7 +146,7 @@ namespace Aws Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; - + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; @@ -266,23 +266,23 @@ namespace Aws * Gets the corresponding signer from the signers map by name. */ Aws::Client::AWSAuthSigner* GetSignerByName(const char* name) const; - protected: - - /** - * Creates an HttpRequest instance with the given URI and sets the proper headers from the - * AmazonWebRequest, and finally signs that request with the given the signer. - * The similar member function BuildHttpRequest() does not sign the request. - * This member function is used internally only by clients that perform requests (input operations) using - * event-streams. - */ - std::shared_ptr<Aws::Http::HttpRequest> BuildAndSignHttpRequest(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method, const char* signerName) const; - - /** - * Performs the HTTP request via the HTTP client while enforcing rate limiters - */ - std::shared_ptr<Aws::Http::HttpResponse> MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const; + protected: + + /** + * Creates an HttpRequest instance with the given URI and sets the proper headers from the + * AmazonWebRequest, and finally signs that request with the given the signer. + * The similar member function BuildHttpRequest() does not sign the request. + * This member function is used internally only by clients that perform requests (input operations) using + * event-streams. + */ + std::shared_ptr<Aws::Http::HttpRequest> BuildAndSignHttpRequest(const Aws::Http::URI& uri, + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method, const char* signerName) const; + + /** + * Performs the HTTP request via the HTTP client while enforcing rate limiters + */ + std::shared_ptr<Aws::Http::HttpResponse> MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const; Aws::String m_region; private: /** @@ -374,8 +374,8 @@ namespace Aws const char* requestName = "", const char* signerRegionOverride = nullptr, const char* signerServiceNameOverride = nullptr) const; - - JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const; + + JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const; }; typedef Utils::Outcome<AmazonWebServiceResult<Utils::Xml::XmlDocument>, AWSError<CoreErrors>> XmlOutcome; @@ -435,25 +435,25 @@ namespace Aws const char* requestName = "", const char* signerRegionOverride = nullptr, const char* signerServiceNameOverride = nullptr) const; - - /** - * This is used for event stream response. - */ - XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + + /** + * This is used for event stream response. + */ + XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, const char* singerName = Aws::Auth::SIGV4_SIGNER, const char* signerRegionOverride = nullptr, const char* signerServiceNameOverride = nullptr) const; - - /** - * This is used for event stream response. + + /** + * This is used for event stream response. * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid * name. - */ - XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, + */ + XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, const char* requestName = "", const char* signerRegionOverride = nullptr, const char* signerServiceNameOverride = nullptr) const; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h index ba54baaa83..fa7337fd59 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h @@ -187,7 +187,7 @@ namespace Aws /** * If you certificate file is different from the default, you can tell clients that * aren't using the default trust store where to find your ca file. - * If you are on windows or apple, you likely don't want this. + * If you are on windows or apple, you likely don't want this. */ Aws::String caFile; /** @@ -218,7 +218,7 @@ namespace Aws * payload to wire if server respond error immediately after receiving the header. * Set this option to true will tell Curl to send http request header and body together. * This can save one round-trip time and especially useful when the payload is small and network latency is more important. - * 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. + * 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. * The default value will be false. */ bool disableExpectHeader; @@ -227,22 +227,22 @@ namespace Aws * If set to true clock skew will be adjusted after each http attempt, default to true. */ bool enableClockSkewAdjustment; - - /** + + /** * Enable host prefix injection. - * 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. + * 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. * Default to true, enabled. You can disable it for testing purpose. - */ - bool enableHostPrefixInjection; - - /** + */ + bool enableHostPrefixInjection; + + /** * Enable endpoint discovery * For some services to dynamically set up their endpoints for different requests. - * Defaults to false, it's an opt-in feature. - * If disabled, regional or overriden endpoint will be used instead. - * If a request requires endpoint discovery but you disabled it. The request will never succeed. - */ - bool enableEndpointDiscovery; + * Defaults to false, it's an opt-in feature. + * If disabled, regional or overriden endpoint will be used instead. + * If a request requires endpoint discovery but you disabled it. The request will never succeed. + */ + bool enableEndpointDiscovery; /** * profileName in config file that will be used by this object to reslove more configurations. diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h index 52ebe51c82..f56bd6c7ba 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h @@ -60,17 +60,17 @@ namespace Aws * Finds a CoreErrors member if possible. Otherwise, returns UNKNOWN */ AWS_CORE_API AWSError<CoreErrors> GetErrorForName(const char* errorName); - - /** - * Build the mapping between predefined exception names and Aws CoreErrors using Aws::Map. - */ - AWS_CORE_API void InitCoreErrorsMapper(); - - /** - * Cleanup memory allocated for Aws::Map used by AWS CoreError Mapper. - */ - AWS_CORE_API void CleanupCoreErrorsMapper(); + /** + * Build the mapping between predefined exception names and Aws CoreErrors using Aws::Map. + */ + AWS_CORE_API void InitCoreErrorsMapper(); + + /** + * Cleanup memory allocated for Aws::Map used by AWS CoreError Mapper. + */ + AWS_CORE_API void CleanupCoreErrorsMapper(); + /** * Finds a CoreErrors member if possible by HTTP response code */ AWS_CORE_API AWSError<CoreErrors> GetErrorForHttpResponseCode(Aws::Http::HttpResponseCode code); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h index 84c62713da..1ada728197 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h @@ -6,8 +6,8 @@ #pragma once #include <aws/core/utils/memory/stl/AWSString.h> -#include <aws/core/utils/memory/stl/AWSMap.h> -#include <aws/core/auth/AWSCredentials.h> +#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/auth/AWSCredentials.h> #include <aws/core/utils/DateTime.h> #include <aws/core/utils/threading/ReaderWriterLock.h> @@ -38,13 +38,13 @@ namespace Aws inline void SetExternalId(const Aws::String& value) { m_externalId = value; } inline const Aws::String& GetSourceProfile() const { return m_sourceProfile; } inline void SetSourceProfile(const Aws::String& value ) { m_sourceProfile = value; } - inline const Aws::String& GetCredentialProcess() const { return m_credentialProcess; } - inline void SetCredentialProcess(const Aws::String& value ) { m_credentialProcess = value; } + inline const Aws::String& GetCredentialProcess() const { return m_credentialProcess; } + inline void SetCredentialProcess(const Aws::String& value ) { m_credentialProcess = value; } inline void SetAllKeyValPairs(const Aws::Map<Aws::String, Aws::String>& map) { m_allKeyValPairs = map; } inline const Aws::String GetValue(const Aws::String& key) const { auto iter = m_allKeyValPairs.find(key); - if (iter == m_allKeyValPairs.end()) return {}; + if (iter == m_allKeyValPairs.end()) return {}; return iter->second; } @@ -55,7 +55,7 @@ namespace Aws Aws::String m_roleArn; Aws::String m_externalId; Aws::String m_sourceProfile; - Aws::String m_credentialProcess; + Aws::String m_credentialProcess; Aws::Map<Aws::String, Aws::String> m_allKeyValPairs; }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h index 9a010a67db..3645a45923 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h @@ -103,17 +103,17 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ */ -/* Decide calling convention based on the cmake parameters defined in C++ SDK. */ -#ifdef USE_IMPORT_EXPORT -#ifdef AWS_CORE_EXPORTS -#define CJSON_EXPORT_SYMBOLS -#else -#define CJSON_IMPORT_SYMBOLS -#endif // AWS_CORE_EXPORTS -#else -#define CJSON_HIDE_SYMBOLS -#endif // USE_IMPORT_EXPORT - +/* Decide calling convention based on the cmake parameters defined in C++ SDK. */ +#ifdef USE_IMPORT_EXPORT +#ifdef AWS_CORE_EXPORTS +#define CJSON_EXPORT_SYMBOLS +#else +#define CJSON_IMPORT_SYMBOLS +#endif // AWS_CORE_EXPORTS +#else +#define CJSON_HIDE_SYMBOLS +#endif // USE_IMPORT_EXPORT + /* export symbols by default, this is necessary for copy pasting the C and header file */ #if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) #define CJSON_EXPORT_SYMBOLS diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h index ab71a3a29b..0859042937 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h @@ -419,31 +419,31 @@ namespace Aws { SetHeaderValue(VIA_HEADER, value); } - - /** - * Has Api version header x-amz-api-version - */ - inline bool HasApiVersion() const - { - return HasHeader(API_VERSION_HEADER); - } - - /** - * Gets Api version header x-amz-api-version. - */ - inline const Aws::String& GetApiVersion() const - { - return GetHeaderValue(API_VERSION_HEADER); - } - /** - * Sets Api version header x-amz-api-version. - */ - inline void SetApiVersion(const Aws::String& value) - { - SetHeaderValue(API_VERSION_HEADER, value); - } - - /** + + /** + * Has Api version header x-amz-api-version + */ + inline bool HasApiVersion() const + { + return HasHeader(API_VERSION_HEADER); + } + + /** + * Gets Api version header x-amz-api-version. + */ + inline const Aws::String& GetApiVersion() const + { + return GetHeaderValue(API_VERSION_HEADER); + } + /** + * Sets Api version header x-amz-api-version. + */ + inline void SetApiVersion(const Aws::String& value) + { + SetHeaderValue(API_VERSION_HEADER, value); + } + + /** * Sets the closure for receiving events when data is received from the server. */ inline void SetDataReceivedEventHandler(const DataReceivedEventHandler& dataReceivedEventHandler) { m_onDataReceived = dataReceivedEventHandler; } @@ -514,15 +514,15 @@ namespace Aws */ virtual const Aws::Monitoring::HttpClientMetricsCollection& GetRequestMetrics() const { return m_httpRequestMetrics; } - /** - * Returns the IP address of the remote host the request was made out to. - * This value is populated after the request is made and when the HTTP client supports retrieving such - * information. - * If the information is not available, an empty string is returned. - */ - Aws::String GetResolvedRemoteHost() const { return m_resolvedRemoteHost; } - void SetResolvedRemoteHost(const Aws::String& ip) { m_resolvedRemoteHost = ip; } - + /** + * Returns the IP address of the remote host the request was made out to. + * This value is populated after the request is made and when the HTTP client supports retrieving such + * information. + * If the information is not available, an empty string is returned. + */ + Aws::String GetResolvedRemoteHost() const { return m_resolvedRemoteHost; } + void SetResolvedRemoteHost(const Aws::String& ip) { m_resolvedRemoteHost = ip; } + bool IsEventStreamRequest() { return m_isEvenStreamRequest; } void SetEventStreamRequest(bool eventStreamRequest) { m_isEvenStreamRequest = eventStreamRequest; } private: @@ -534,7 +534,7 @@ namespace Aws ContinueRequestHandler m_continueRequest; Aws::String m_signingRegion; Aws::String m_signingAccessKey; - Aws::String m_resolvedRemoteHost; + Aws::String m_resolvedRemoteHost; Aws::Monitoring::HttpClientMetricsCollection m_httpRequestMetrics; }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DNS.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DNS.h index 7472a386c0..51589ecacd 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DNS.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DNS.h @@ -12,7 +12,7 @@ namespace Aws namespace Utils { AWS_CORE_API bool IsValidDnsLabel(const Aws::String& label); - - AWS_CORE_API bool IsValidHost(const Aws::String& host); + + AWS_CORE_API bool IsValidHost(const Aws::String& host); } } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h index 312342b86a..f41dccac9d 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h @@ -181,13 +181,13 @@ namespace Aws return os.str(); } - /** - * locale agnostic implementation of std::isalnum - */ - static bool IsAlnum(char c) - { - return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); - } + /** + * locale agnostic implementation of std::isalnum + */ + static bool IsAlnum(char c) + { + return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); + } /** * Convert an unsigned integer to its hex string in upper case. diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h index c60dda0435..762b1aa686 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h @@ -1,311 +1,311 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/utils/memory/stl/AWSString.h> -#include <aws/core/utils/Array.h> -#include <aws/core/utils/memory/stl/AWSMap.h> -#include <aws/core/utils/UUID.h> -#include <aws/core/utils/logging/LogMacros.h> -#include <aws/event-stream/event_stream.h> -#include <cassert> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - static const char CLASS_TAG[] = "EventHeader"; - /** - * Interface of the header value of a message in event stream. - * Each type of header value should have it's own associated derived class based on this class. - */ - class AWS_CORE_API EventHeaderValue - { - public: - enum class EventHeaderType - { - BOOL_TRUE = 0, - BOOL_FALSE, - BYTE, - INT16, - INT32, - INT64, - BYTE_BUF, - STRING, - /* 64 bit integer (millis since epoch) */ - TIMESTAMP, - UUID, - UNKNOWN - }; - - EventHeaderValue() = default; - - EventHeaderValue(aws_event_stream_header_value_pair* header) : - m_eventHeaderType(static_cast<EventHeaderType>(header->header_value_type)) - { - switch (m_eventHeaderType) - { - case EventHeaderType::BOOL_TRUE: - case EventHeaderType::BOOL_FALSE: - m_eventHeaderStaticValue.boolValue = aws_event_stream_header_value_as_bool(header) != 0; - break; - case EventHeaderType::BYTE: - m_eventHeaderStaticValue.byteValue = aws_event_stream_header_value_as_byte(header); - break; - case EventHeaderType::INT16: - m_eventHeaderStaticValue.int16Value = aws_event_stream_header_value_as_int16(header); - break; - case EventHeaderType::INT32: - m_eventHeaderStaticValue.int32Value = aws_event_stream_header_value_as_int32(header); - break; - case EventHeaderType::INT64: - m_eventHeaderStaticValue.int64Value = aws_event_stream_header_value_as_int64(header); - break; - case EventHeaderType::BYTE_BUF: - m_eventHeaderVariableLengthValue = ByteBuffer(static_cast<uint8_t*>(aws_event_stream_header_value_as_bytebuf(header).buffer), header->header_value_len); - break; - case EventHeaderType::STRING: - m_eventHeaderVariableLengthValue = ByteBuffer(static_cast<uint8_t*>(aws_event_stream_header_value_as_string(header).buffer), header->header_value_len); - break; - case EventHeaderType::TIMESTAMP: - m_eventHeaderStaticValue.timestampValue = aws_event_stream_header_value_as_timestamp(header); - break; - case EventHeaderType::UUID: - assert(header->header_value_len == 16u); - m_eventHeaderVariableLengthValue = ByteBuffer(static_cast<uint8_t*>(aws_event_stream_header_value_as_uuid(header).buffer), header->header_value_len); - break; - default: - AWS_LOG_ERROR(CLASS_TAG, "Encountered unknown type of header."); - break; - } - }; - - EventHeaderValue(const Aws::String& s) : - m_eventHeaderType(EventHeaderType::STRING), - m_eventHeaderVariableLengthValue(reinterpret_cast<const uint8_t*>(s.data()), s.length()) - { - } - - EventHeaderValue(const ByteBuffer& bb) : - m_eventHeaderType(EventHeaderType::BYTE_BUF), - m_eventHeaderVariableLengthValue(bb) - { - } - - EventHeaderValue(ByteBuffer&& bb) : - m_eventHeaderType(EventHeaderType::BYTE_BUF), - m_eventHeaderVariableLengthValue(std::move(bb)) - { - } - - - explicit EventHeaderValue(unsigned char byte) : - m_eventHeaderType(EventHeaderType::BYTE) - { - m_eventHeaderStaticValue.byteValue = byte; - } - - explicit EventHeaderValue(bool b) : - m_eventHeaderType(b ? EventHeaderType::BOOL_TRUE : EventHeaderType::BOOL_FALSE) - { - m_eventHeaderStaticValue.boolValue = b; - } - - explicit EventHeaderValue(int16_t n) : - m_eventHeaderType(EventHeaderType::INT16) - { - m_eventHeaderStaticValue.int16Value = n; - } - - explicit EventHeaderValue(int32_t n) : - m_eventHeaderType(EventHeaderType::INT32) - { - m_eventHeaderStaticValue.int32Value = n; - } - - explicit EventHeaderValue(int64_t n, EventHeaderType type = EventHeaderType::INT64) : - m_eventHeaderType(type) - { - if (type == EventHeaderType::TIMESTAMP) - { - m_eventHeaderStaticValue.timestampValue = n; - } - else - { - m_eventHeaderStaticValue.int64Value = n; - } - } - - EventHeaderType GetType() const { return m_eventHeaderType; } - - - static EventHeaderType GetEventHeaderTypeForName(const Aws::String& name); - static Aws::String GetNameForEventHeaderType(EventHeaderType value); - - /** - * Get header value as boolean. - * Log error if derived class doesn't override this function. - */ - inline bool GetEventHeaderValueAsBoolean() const - { - assert(m_eventHeaderType == EventHeaderType::BOOL_TRUE || m_eventHeaderType == EventHeaderType::BOOL_FALSE); - if (m_eventHeaderType != EventHeaderType::BOOL_TRUE && m_eventHeaderType != EventHeaderType::BOOL_FALSE) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is TRUE or FALSE, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return false; - } - return m_eventHeaderStaticValue.boolValue; - } - - /** - * Get header value as byte. - * Log error if derived class doesn't override this function. - */ - inline uint8_t GetEventHeaderValueAsByte() const - { - assert(m_eventHeaderType == EventHeaderType::BYTE); - if (m_eventHeaderType != EventHeaderType::BYTE) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is BYTE, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return static_cast<uint8_t>(0); - } - return m_eventHeaderStaticValue.byteValue; - } - - /** - * Get header value as 16 bit integer. - * Log error if derived class doesn't override this function. - */ - inline int16_t GetEventHeaderValueAsInt16() const - { - assert(m_eventHeaderType == EventHeaderType::INT16); - if (m_eventHeaderType != EventHeaderType::INT16) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is INT16, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return static_cast<int16_t>(0); - } - return m_eventHeaderStaticValue.int16Value; - } - - /** - * Get header value as 32 bit integer. - * Log error if derived class doesn't override this function. - */ - inline int32_t GetEventHeaderValueAsInt32() const - { - assert(m_eventHeaderType == EventHeaderType::INT32); - if (m_eventHeaderType != EventHeaderType::INT32) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is INT32, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return static_cast<int32_t>(0); - } - return m_eventHeaderStaticValue.int32Value; - } - - /** - * Get header value as 64 bit integer. - * Log error if derived class doesn't override this function. - */ - inline int64_t GetEventHeaderValueAsInt64() const - { - assert(m_eventHeaderType == EventHeaderType::INT64); - if (m_eventHeaderType != EventHeaderType::INT64) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is INT64, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return static_cast<uint64_t>(0); - } - return m_eventHeaderStaticValue.int64Value; - } - - /** - * Get header value as ByteBuffer. - * Log error if derived class doesn't override this function. - */ - inline ByteBuffer GetEventHeaderValueAsBytebuf() const - { - assert(m_eventHeaderType == EventHeaderType::BYTE_BUF); - if (m_eventHeaderType != EventHeaderType::BYTE_BUF) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is BYTE_BUF, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return ByteBuffer(); - } - return m_eventHeaderVariableLengthValue; - } - - /** - * Get header value as String. - * Log error if derived class doesn't override this function. - */ - inline Aws::String GetEventHeaderValueAsString() const - { - assert(m_eventHeaderType == EventHeaderType::STRING); - if (m_eventHeaderType != EventHeaderType::STRING) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is STRING, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return {}; - } - return Aws::String(reinterpret_cast<char*>(m_eventHeaderVariableLengthValue.GetUnderlyingData()), m_eventHeaderVariableLengthValue.GetLength()); - } - - /** - * Get header value as timestamp in 64 bit integer. - * Log error if derived class doesn't override this function. - */ - inline int64_t GetEventHeaderValueAsTimestamp() const - { - assert(m_eventHeaderType == EventHeaderType::TIMESTAMP); - if (m_eventHeaderType != EventHeaderType::TIMESTAMP) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is TIMESTAMP, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - return static_cast<int64_t>(0); - } - return m_eventHeaderStaticValue.timestampValue; - } - - /** - * Get header value as UUID. - * Log error if derived class doesn't override this function. - */ - inline Aws::Utils::UUID GetEventHeaderValueAsUuid() const - { - assert(m_eventHeaderType == EventHeaderType::UUID); - assert(m_eventHeaderVariableLengthValue.GetLength() == 16u); - if (m_eventHeaderType != EventHeaderType::UUID) - { - AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is UUID, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); - char uuid[32] = {0}; - return Aws::Utils::UUID(uuid); - } - return Aws::Utils::UUID(m_eventHeaderVariableLengthValue.GetUnderlyingData()); - } - - inline const ByteBuffer& GetUnderlyingBuffer() const - { - return m_eventHeaderVariableLengthValue; - } - - private: - EventHeaderType m_eventHeaderType; - ByteBuffer m_eventHeaderVariableLengthValue; - union - { - bool boolValue; - uint8_t byteValue; - int16_t int16Value; - int32_t int32Value; - int64_t int64Value; - int64_t timestampValue; - } m_eventHeaderStaticValue; - }; - - typedef std::pair<Aws::String, EventHeaderValue> EventHeaderValuePair; - typedef Aws::Map<Aws::String, EventHeaderValue> EventHeaderValueCollection; - } - } -} + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/Array.h> +#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/utils/UUID.h> +#include <aws/core/utils/logging/LogMacros.h> +#include <aws/event-stream/event_stream.h> +#include <cassert> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + static const char CLASS_TAG[] = "EventHeader"; + /** + * Interface of the header value of a message in event stream. + * Each type of header value should have it's own associated derived class based on this class. + */ + class AWS_CORE_API EventHeaderValue + { + public: + enum class EventHeaderType + { + BOOL_TRUE = 0, + BOOL_FALSE, + BYTE, + INT16, + INT32, + INT64, + BYTE_BUF, + STRING, + /* 64 bit integer (millis since epoch) */ + TIMESTAMP, + UUID, + UNKNOWN + }; + + EventHeaderValue() = default; + + EventHeaderValue(aws_event_stream_header_value_pair* header) : + m_eventHeaderType(static_cast<EventHeaderType>(header->header_value_type)) + { + switch (m_eventHeaderType) + { + case EventHeaderType::BOOL_TRUE: + case EventHeaderType::BOOL_FALSE: + m_eventHeaderStaticValue.boolValue = aws_event_stream_header_value_as_bool(header) != 0; + break; + case EventHeaderType::BYTE: + m_eventHeaderStaticValue.byteValue = aws_event_stream_header_value_as_byte(header); + break; + case EventHeaderType::INT16: + m_eventHeaderStaticValue.int16Value = aws_event_stream_header_value_as_int16(header); + break; + case EventHeaderType::INT32: + m_eventHeaderStaticValue.int32Value = aws_event_stream_header_value_as_int32(header); + break; + case EventHeaderType::INT64: + m_eventHeaderStaticValue.int64Value = aws_event_stream_header_value_as_int64(header); + break; + case EventHeaderType::BYTE_BUF: + m_eventHeaderVariableLengthValue = ByteBuffer(static_cast<uint8_t*>(aws_event_stream_header_value_as_bytebuf(header).buffer), header->header_value_len); + break; + case EventHeaderType::STRING: + m_eventHeaderVariableLengthValue = ByteBuffer(static_cast<uint8_t*>(aws_event_stream_header_value_as_string(header).buffer), header->header_value_len); + break; + case EventHeaderType::TIMESTAMP: + m_eventHeaderStaticValue.timestampValue = aws_event_stream_header_value_as_timestamp(header); + break; + case EventHeaderType::UUID: + assert(header->header_value_len == 16u); + m_eventHeaderVariableLengthValue = ByteBuffer(static_cast<uint8_t*>(aws_event_stream_header_value_as_uuid(header).buffer), header->header_value_len); + break; + default: + AWS_LOG_ERROR(CLASS_TAG, "Encountered unknown type of header."); + break; + } + }; + + EventHeaderValue(const Aws::String& s) : + m_eventHeaderType(EventHeaderType::STRING), + m_eventHeaderVariableLengthValue(reinterpret_cast<const uint8_t*>(s.data()), s.length()) + { + } + + EventHeaderValue(const ByteBuffer& bb) : + m_eventHeaderType(EventHeaderType::BYTE_BUF), + m_eventHeaderVariableLengthValue(bb) + { + } + + EventHeaderValue(ByteBuffer&& bb) : + m_eventHeaderType(EventHeaderType::BYTE_BUF), + m_eventHeaderVariableLengthValue(std::move(bb)) + { + } + + + explicit EventHeaderValue(unsigned char byte) : + m_eventHeaderType(EventHeaderType::BYTE) + { + m_eventHeaderStaticValue.byteValue = byte; + } + + explicit EventHeaderValue(bool b) : + m_eventHeaderType(b ? EventHeaderType::BOOL_TRUE : EventHeaderType::BOOL_FALSE) + { + m_eventHeaderStaticValue.boolValue = b; + } + + explicit EventHeaderValue(int16_t n) : + m_eventHeaderType(EventHeaderType::INT16) + { + m_eventHeaderStaticValue.int16Value = n; + } + + explicit EventHeaderValue(int32_t n) : + m_eventHeaderType(EventHeaderType::INT32) + { + m_eventHeaderStaticValue.int32Value = n; + } + + explicit EventHeaderValue(int64_t n, EventHeaderType type = EventHeaderType::INT64) : + m_eventHeaderType(type) + { + if (type == EventHeaderType::TIMESTAMP) + { + m_eventHeaderStaticValue.timestampValue = n; + } + else + { + m_eventHeaderStaticValue.int64Value = n; + } + } + + EventHeaderType GetType() const { return m_eventHeaderType; } + + + static EventHeaderType GetEventHeaderTypeForName(const Aws::String& name); + static Aws::String GetNameForEventHeaderType(EventHeaderType value); + + /** + * Get header value as boolean. + * Log error if derived class doesn't override this function. + */ + inline bool GetEventHeaderValueAsBoolean() const + { + assert(m_eventHeaderType == EventHeaderType::BOOL_TRUE || m_eventHeaderType == EventHeaderType::BOOL_FALSE); + if (m_eventHeaderType != EventHeaderType::BOOL_TRUE && m_eventHeaderType != EventHeaderType::BOOL_FALSE) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is TRUE or FALSE, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return false; + } + return m_eventHeaderStaticValue.boolValue; + } + + /** + * Get header value as byte. + * Log error if derived class doesn't override this function. + */ + inline uint8_t GetEventHeaderValueAsByte() const + { + assert(m_eventHeaderType == EventHeaderType::BYTE); + if (m_eventHeaderType != EventHeaderType::BYTE) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is BYTE, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return static_cast<uint8_t>(0); + } + return m_eventHeaderStaticValue.byteValue; + } + + /** + * Get header value as 16 bit integer. + * Log error if derived class doesn't override this function. + */ + inline int16_t GetEventHeaderValueAsInt16() const + { + assert(m_eventHeaderType == EventHeaderType::INT16); + if (m_eventHeaderType != EventHeaderType::INT16) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is INT16, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return static_cast<int16_t>(0); + } + return m_eventHeaderStaticValue.int16Value; + } + + /** + * Get header value as 32 bit integer. + * Log error if derived class doesn't override this function. + */ + inline int32_t GetEventHeaderValueAsInt32() const + { + assert(m_eventHeaderType == EventHeaderType::INT32); + if (m_eventHeaderType != EventHeaderType::INT32) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is INT32, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return static_cast<int32_t>(0); + } + return m_eventHeaderStaticValue.int32Value; + } + + /** + * Get header value as 64 bit integer. + * Log error if derived class doesn't override this function. + */ + inline int64_t GetEventHeaderValueAsInt64() const + { + assert(m_eventHeaderType == EventHeaderType::INT64); + if (m_eventHeaderType != EventHeaderType::INT64) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is INT64, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return static_cast<uint64_t>(0); + } + return m_eventHeaderStaticValue.int64Value; + } + + /** + * Get header value as ByteBuffer. + * Log error if derived class doesn't override this function. + */ + inline ByteBuffer GetEventHeaderValueAsBytebuf() const + { + assert(m_eventHeaderType == EventHeaderType::BYTE_BUF); + if (m_eventHeaderType != EventHeaderType::BYTE_BUF) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is BYTE_BUF, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return ByteBuffer(); + } + return m_eventHeaderVariableLengthValue; + } + + /** + * Get header value as String. + * Log error if derived class doesn't override this function. + */ + inline Aws::String GetEventHeaderValueAsString() const + { + assert(m_eventHeaderType == EventHeaderType::STRING); + if (m_eventHeaderType != EventHeaderType::STRING) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is STRING, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return {}; + } + return Aws::String(reinterpret_cast<char*>(m_eventHeaderVariableLengthValue.GetUnderlyingData()), m_eventHeaderVariableLengthValue.GetLength()); + } + + /** + * Get header value as timestamp in 64 bit integer. + * Log error if derived class doesn't override this function. + */ + inline int64_t GetEventHeaderValueAsTimestamp() const + { + assert(m_eventHeaderType == EventHeaderType::TIMESTAMP); + if (m_eventHeaderType != EventHeaderType::TIMESTAMP) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is TIMESTAMP, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + return static_cast<int64_t>(0); + } + return m_eventHeaderStaticValue.timestampValue; + } + + /** + * Get header value as UUID. + * Log error if derived class doesn't override this function. + */ + inline Aws::Utils::UUID GetEventHeaderValueAsUuid() const + { + assert(m_eventHeaderType == EventHeaderType::UUID); + assert(m_eventHeaderVariableLengthValue.GetLength() == 16u); + if (m_eventHeaderType != EventHeaderType::UUID) + { + AWS_LOGSTREAM_ERROR(CLASS_TAG, "Expected event header type is UUID, but encountered " << GetNameForEventHeaderType(m_eventHeaderType)); + char uuid[32] = {0}; + return Aws::Utils::UUID(uuid); + } + return Aws::Utils::UUID(m_eventHeaderVariableLengthValue.GetUnderlyingData()); + } + + inline const ByteBuffer& GetUnderlyingBuffer() const + { + return m_eventHeaderVariableLengthValue; + } + + private: + EventHeaderType m_eventHeaderType; + ByteBuffer m_eventHeaderVariableLengthValue; + union + { + bool boolValue; + uint8_t byteValue; + int16_t int16Value; + int32_t int32Value; + int64_t int64Value; + int64_t timestampValue; + } m_eventHeaderStaticValue; + }; + + typedef std::pair<Aws::String, EventHeaderValue> EventHeaderValuePair; + typedef Aws::Map<Aws::String, EventHeaderValue> EventHeaderValueCollection; + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h index 4540fbe79c..7d8ef59914 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h @@ -1,42 +1,42 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/utils/event/EventHeader.h> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - extern AWS_CORE_API const char EVENT_TYPE_HEADER[]; - extern AWS_CORE_API const char CONTENT_TYPE_HEADER[]; - extern AWS_CORE_API const char MESSAGE_TYPE_HEADER[]; - extern AWS_CORE_API const char ERROR_CODE_HEADER[]; - extern AWS_CORE_API const char ERROR_MESSAGE_HEADER[]; + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/event/EventHeader.h> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + extern AWS_CORE_API const char EVENT_TYPE_HEADER[]; + extern AWS_CORE_API const char CONTENT_TYPE_HEADER[]; + extern AWS_CORE_API const char MESSAGE_TYPE_HEADER[]; + extern AWS_CORE_API const char ERROR_CODE_HEADER[]; + extern AWS_CORE_API const char ERROR_MESSAGE_HEADER[]; extern AWS_CORE_API const char EXCEPTION_TYPE_HEADER[]; - - /** - * A typical message in event stream consists of two parts: Prelude and Data, as well as the prelude CRC and message CRC. - * Prelude consists of total byte length and headers byte length. - * Data consists of headers and payload. - */ - class AWS_CORE_API Message - { - public: - enum class MessageType - { - UNKNOWN, - EVENT, + + /** + * A typical message in event stream consists of two parts: Prelude and Data, as well as the prelude CRC and message CRC. + * Prelude consists of total byte length and headers byte length. + * Data consists of headers and payload. + */ + class AWS_CORE_API Message + { + public: + enum class MessageType + { + UNKNOWN, + EVENT, REQUEST_LEVEL_ERROR, REQUEST_LEVEL_EXCEPTION - }; - + }; + enum class ContentType { UNKNOWN, @@ -45,78 +45,78 @@ namespace Aws TEXT_PLAIN }; - static MessageType GetMessageTypeForName(const Aws::String& name); - static Aws::String GetNameForMessageType(MessageType value); - + static MessageType GetMessageTypeForName(const Aws::String& name); + static Aws::String GetNameForMessageType(MessageType value); + static ContentType GetContentTypeForName(const Aws::String& name); static Aws::String GetNameForContentType(ContentType value); - /** - * Clean up the message, including the metadata, headers and payload received. - */ - void Reset(); - - /** - * Get/set the total length of this message: prelude(8 bytes) + prelude CRC(4 bytes) + Data(headers length + payload length) + message CRC(4 bytes). - */ - inline void SetTotalLength(size_t length) - { - m_totalLength = length; - m_eventPayload.reserve(length); - } - - inline size_t GetTotalLength() const { return m_totalLength; } - - /** - * Get/set the length of the headers. - * Each header consists of: header name byte-length(1 byte) + header name + header value type(1 byte) + header value. - */ - inline void SetHeadersLength(size_t length) { m_headersLength = length; } - inline size_t GetHeadersLength() const { return m_headersLength; } - - /** - * Get/set the length of payload. - */ - inline void SetPayloadLength(size_t length) { m_payloadLength = length; } - inline size_t GetPayloadLength() const { return m_payloadLength; } - - /** - * Set/get event headers. - */ - inline void InsertEventHeader(const Aws::String& headerName, const EventHeaderValue& eventHeaderValue) - { - m_eventHeaders.emplace(Aws::Utils::Event::EventHeaderValuePair(headerName, eventHeaderValue)); - } - - inline const Aws::Utils::Event::EventHeaderValueCollection& GetEventHeaders() const { return m_eventHeaders; } - - /** - * Set event payload. - */ + /** + * Clean up the message, including the metadata, headers and payload received. + */ + void Reset(); + + /** + * Get/set the total length of this message: prelude(8 bytes) + prelude CRC(4 bytes) + Data(headers length + payload length) + message CRC(4 bytes). + */ + inline void SetTotalLength(size_t length) + { + m_totalLength = length; + m_eventPayload.reserve(length); + } + + inline size_t GetTotalLength() const { return m_totalLength; } + + /** + * Get/set the length of the headers. + * Each header consists of: header name byte-length(1 byte) + header name + header value type(1 byte) + header value. + */ + inline void SetHeadersLength(size_t length) { m_headersLength = length; } + inline size_t GetHeadersLength() const { return m_headersLength; } + + /** + * Get/set the length of payload. + */ + inline void SetPayloadLength(size_t length) { m_payloadLength = length; } + inline size_t GetPayloadLength() const { return m_payloadLength; } + + /** + * Set/get event headers. + */ + inline void InsertEventHeader(const Aws::String& headerName, const EventHeaderValue& eventHeaderValue) + { + m_eventHeaders.emplace(Aws::Utils::Event::EventHeaderValuePair(headerName, eventHeaderValue)); + } + + inline const Aws::Utils::Event::EventHeaderValueCollection& GetEventHeaders() const { return m_eventHeaders; } + + /** + * Set event payload. + */ void WriteEventPayload(const unsigned char* data, size_t length); - void WriteEventPayload(const Aws::Vector<unsigned char>& bits); + void WriteEventPayload(const Aws::Vector<unsigned char>& bits); void WriteEventPayload(const Aws::String& bits); - /** - * Get the byte array of the payload with transferring ownership. - */ - Aws::Vector<unsigned char>&& GetEventPayloadWithOwnership() { return std::move(m_eventPayload); } - const Aws::Vector<unsigned char>& GetEventPayload() const { return m_eventPayload; } - Aws::Vector<unsigned char>& GetEventPayload() { return m_eventPayload; } - /** - * Convert byte array of the payload to string without transferring ownership. - */ - inline Aws::String GetEventPayloadAsString() { return Aws::String(m_eventPayload.begin(), m_eventPayload.end()); } - - private: - size_t m_totalLength; - size_t m_headersLength; - size_t m_payloadLength; - - Aws::Utils::Event::EventHeaderValueCollection m_eventHeaders; - Aws::Vector<unsigned char> m_eventPayload; - }; - - } - } -} + /** + * Get the byte array of the payload with transferring ownership. + */ + Aws::Vector<unsigned char>&& GetEventPayloadWithOwnership() { return std::move(m_eventPayload); } + const Aws::Vector<unsigned char>& GetEventPayload() const { return m_eventPayload; } + Aws::Vector<unsigned char>& GetEventPayload() { return m_eventPayload; } + /** + * Convert byte array of the payload to string without transferring ownership. + */ + inline Aws::String GetEventPayloadAsString() { return Aws::String(m_eventPayload.begin(), m_eventPayload.end()); } + + private: + size_t m_totalLength; + size_t m_headersLength; + size_t m_payloadLength; + + Aws::Utils::Event::EventHeaderValueCollection m_eventHeaders; + Aws::Vector<unsigned char> m_eventPayload; + }; + + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStream.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStream.h index daa9cbf57d..08f1e051be 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStream.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStream.h @@ -1,8 +1,8 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#pragma once - + */ +#pragma once + #include <aws/core/utils/event/EventDecoderStream.h> #include <aws/core/utils/event/EventEncoderStream.h> diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamBuf.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamBuf.h index ad5c440323..a22a578955 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamBuf.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamBuf.h @@ -1,52 +1,52 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <ios> -#include <aws/core/utils/event/EventStreamDecoder.h> -#include <aws/core/utils/memory/stl/AWSStringStream.h> - -namespace Aws -{ - namespace Utils - { - namespace Event - { + */ +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <ios> +#include <aws/core/utils/event/EventStreamDecoder.h> +#include <aws/core/utils/memory/stl/AWSStringStream.h> + +namespace Aws +{ + namespace Utils + { + namespace Event + { extern AWS_CORE_API const size_t DEFAULT_BUF_SIZE; - - /** - * Derived from std::streambuf, used as the underlying buffer for EventStream. - * Handle the payload from server side and pass data to underlying decoder. - */ - class AWS_CORE_API EventStreamBuf : public std::streambuf - { - public: - /** - * @param decoder decodes the stream from server side, so as to invoke related callback functions. + + /** + * Derived from std::streambuf, used as the underlying buffer for EventStream. + * Handle the payload from server side and pass data to underlying decoder. + */ + class AWS_CORE_API EventStreamBuf : public std::streambuf + { + public: + /** + * @param decoder decodes the stream from server side, so as to invoke related callback functions. * @param bufferSize The length of buffer, will be 1024 bytes by default. - */ - EventStreamBuf(EventStreamDecoder& decoder, size_t bufferLength = DEFAULT_BUF_SIZE); - virtual ~EventStreamBuf(); - - protected: - std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; - std::streampos seekpos(std::streampos pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; - - int underflow() override; - int overflow(int ch) override; - int sync() override; - - private: - void writeToDecoder(); - - ByteBuffer m_byteBuffer; - size_t m_bufferLength; - Aws::StringStream m_err; - EventStreamDecoder& m_decoder; - }; - } - } -} + */ + EventStreamBuf(EventStreamDecoder& decoder, size_t bufferLength = DEFAULT_BUF_SIZE); + virtual ~EventStreamBuf(); + + protected: + std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; + std::streampos seekpos(std::streampos pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; + + int underflow() override; + int overflow(int ch) override; + int sync() override; + + private: + void writeToDecoder(); + + ByteBuffer m_byteBuffer; + size_t m_bufferLength; + Aws::StringStream m_err; + EventStreamDecoder& m_decoder; + }; + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamDecoder.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamDecoder.h index 8f737e7bc7..f1ce3fbfbf 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamDecoder.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamDecoder.h @@ -1,109 +1,109 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/utils/Array.h> -#include <aws/core/utils/event/EventStreamHandler.h> -#include <aws/event-stream/event_stream.h> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - class AWS_CORE_API EventStreamDecoder - { - public: - EventStreamDecoder(EventStreamHandler* handler); - ~EventStreamDecoder(); - - /** - * Whether or not the decoder is in good state. Return false if the decoder encounters errors. - */ + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/Array.h> +#include <aws/core/utils/event/EventStreamHandler.h> +#include <aws/event-stream/event_stream.h> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + class AWS_CORE_API EventStreamDecoder + { + public: + EventStreamDecoder(EventStreamHandler* handler); + ~EventStreamDecoder(); + + /** + * Whether or not the decoder is in good state. Return false if the decoder encounters errors. + */ inline explicit operator bool() const { return *m_eventStreamHandler; } - - /** - * A wrapper of aws_event_stream_streaming_decoder_pump in aws-c-event-stream. - * Pass data to the underlying decoder. - */ - void Pump(const ByteBuffer& data); - void Pump(const ByteBuffer& data, size_t length); - - /** - * Reset decoder and it's handler. - */ - void Reset(); - - /** - * Reset event stream handler of the decoder - */ - void ResetEventStreamHandler(EventStreamHandler* handler); - - protected: - /** - * Callback function invoked when payload data has been received. - * @param decoder The underlying decoder defined in the aws-c-event-stream. - * @param payload The payload data received, it doesn't belong to you, make a copy if necessary. - * @param isFinalSegment A flag indicates the current data is the last payload buffer for that message if it equals to 1. - * @param context A context pointer, will cast it to a pointer of flow handler. - */ - static void onPayloadSegment( - aws_event_stream_streaming_decoder* decoder, - aws_byte_buf* payload, - int8_t isFinalSegment, - void* context); - - /** - * Callback function invoked when a new message has arrived. - * @param decoder The underlying decoder defined in the aws-c-event-stream. - * @param prelude The metadata of the message, including total message length and header length. - * @param context A context pointer, will cast it to a pointer of flow handler. - */ - static void onPreludeReceived( - aws_event_stream_streaming_decoder* decoder, - aws_event_stream_message_prelude* prelude, - void* context); - - /** - * Callback function invoked when a header is encountered. - * @param decoder The underlying decoder defined in the aws-c-event-stream. - * @param prelude The metadata of the message, including total message length and header length. - * @param header A header of the message. - * @param context A context pointer, will cast it to a pointer of flow handler. - */ - static void onHeaderReceived( - aws_event_stream_streaming_decoder* decoder, - aws_event_stream_message_prelude* prelude, - aws_event_stream_header_value_pair* header, - void* context); - - /** - * Callback function invoked when an error is encountered. - * @param decoder The underlying decoder defined in aws-c-event-stream. - * @param prelude The metadata of the message, including total message length and header length. - * @param errorCode Error code indicates the type of the error encountered. - * @param message Error message indicates the details of the error encountered. - * @param context A context pointer, will cast it to a pointer of flow handler. - */ - static void onError( - aws_event_stream_streaming_decoder* decoder, - aws_event_stream_message_prelude* prelude, - int errorCode, - const char* message, - void* context); - - /** - * The underlying decoder defined in aws-c-event-stream. + + /** + * A wrapper of aws_event_stream_streaming_decoder_pump in aws-c-event-stream. + * Pass data to the underlying decoder. + */ + void Pump(const ByteBuffer& data); + void Pump(const ByteBuffer& data, size_t length); + + /** + * Reset decoder and it's handler. + */ + void Reset(); + + /** + * Reset event stream handler of the decoder + */ + void ResetEventStreamHandler(EventStreamHandler* handler); + + protected: + /** + * Callback function invoked when payload data has been received. + * @param decoder The underlying decoder defined in the aws-c-event-stream. + * @param payload The payload data received, it doesn't belong to you, make a copy if necessary. + * @param isFinalSegment A flag indicates the current data is the last payload buffer for that message if it equals to 1. + * @param context A context pointer, will cast it to a pointer of flow handler. + */ + static void onPayloadSegment( + aws_event_stream_streaming_decoder* decoder, + aws_byte_buf* payload, + int8_t isFinalSegment, + void* context); + + /** + * Callback function invoked when a new message has arrived. + * @param decoder The underlying decoder defined in the aws-c-event-stream. + * @param prelude The metadata of the message, including total message length and header length. + * @param context A context pointer, will cast it to a pointer of flow handler. + */ + static void onPreludeReceived( + aws_event_stream_streaming_decoder* decoder, + aws_event_stream_message_prelude* prelude, + void* context); + + /** + * Callback function invoked when a header is encountered. + * @param decoder The underlying decoder defined in the aws-c-event-stream. + * @param prelude The metadata of the message, including total message length and header length. + * @param header A header of the message. + * @param context A context pointer, will cast it to a pointer of flow handler. + */ + static void onHeaderReceived( + aws_event_stream_streaming_decoder* decoder, + aws_event_stream_message_prelude* prelude, + aws_event_stream_header_value_pair* header, + void* context); + + /** + * Callback function invoked when an error is encountered. + * @param decoder The underlying decoder defined in aws-c-event-stream. + * @param prelude The metadata of the message, including total message length and header length. + * @param errorCode Error code indicates the type of the error encountered. + * @param message Error message indicates the details of the error encountered. + * @param context A context pointer, will cast it to a pointer of flow handler. + */ + static void onError( + aws_event_stream_streaming_decoder* decoder, + aws_event_stream_message_prelude* prelude, + int errorCode, + const char* message, + void* context); + + /** + * The underlying decoder defined in aws-c-event-stream. * The decoder will invoke callback functions when the streaming messages received. - */ - aws_event_stream_streaming_decoder m_decoder; - EventStreamHandler* m_eventStreamHandler; - }; - } - } -} + */ + aws_event_stream_streaming_decoder m_decoder; + EventStreamHandler* m_eventStreamHandler; + }; + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h index 3cd06a9df2..0fd7851824 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h @@ -1,51 +1,51 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/utils/memory/stl/AWSVector.h> -#include <aws/event-stream/event_stream.h> - -namespace Aws -{ - namespace Client - { - class AWSAuthSigner; - } - - namespace Utils - { - namespace Event - { - /** - * Utility class that wraps the logic of translating event messages to their binary format according to the - * AWS streaming specification. - * This class is _not_ thread-safe. - */ - class AWS_CORE_API EventStreamEncoder - { - public: - EventStreamEncoder(Aws::Client::AWSAuthSigner* signer = nullptr); - - - void SetSignatureSeed(const Aws::String& seed) { m_signatureSeed = seed; } - - void SetSigner(Aws::Client::AWSAuthSigner* signer) { m_signer = signer; } - - /** - * Encodes the input message in the event-stream binary format and signs the resulting bits. - * The signing is done via the signer member. - */ - Aws::Vector<unsigned char> EncodeAndSign(const Aws::Utils::Event::Message& msg); - private: - aws_event_stream_message Encode(const Aws::Utils::Event::Message& msg); - aws_event_stream_message Sign(aws_event_stream_message* msg); - Aws::Client::AWSAuthSigner* m_signer; - Aws::String m_signatureSeed; - }; - } - } -} + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/memory/stl/AWSVector.h> +#include <aws/event-stream/event_stream.h> + +namespace Aws +{ + namespace Client + { + class AWSAuthSigner; + } + + namespace Utils + { + namespace Event + { + /** + * Utility class that wraps the logic of translating event messages to their binary format according to the + * AWS streaming specification. + * This class is _not_ thread-safe. + */ + class AWS_CORE_API EventStreamEncoder + { + public: + EventStreamEncoder(Aws::Client::AWSAuthSigner* signer = nullptr); + + + void SetSignatureSeed(const Aws::String& seed) { m_signatureSeed = seed; } + + void SetSigner(Aws::Client::AWSAuthSigner* signer) { m_signer = signer; } + + /** + * Encodes the input message in the event-stream binary format and signs the resulting bits. + * The signing is done via the signer member. + */ + Aws::Vector<unsigned char> EncodeAndSign(const Aws::Utils::Event::Message& msg); + private: + aws_event_stream_message Encode(const Aws::Utils::Event::Message& msg); + aws_event_stream_message Sign(aws_event_stream_message* msg); + Aws::Client::AWSAuthSigner* m_signer; + Aws::String m_signatureSeed; + }; + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamErrors.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamErrors.h index d85e4fdd1f..08789eb1a3 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamErrors.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamErrors.h @@ -1,47 +1,47 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#pragma once - -#include <aws/core/client/CoreErrors.h> -#include <aws/core/Core_EXPORTS.h> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - /** - * Errors encountered in event stream. - * These errors are associated with those in aws-c-event-stream library. - */ - enum class EventStreamErrors - { - EVENT_STREAM_NO_ERROR = 0, - EVENT_STREAM_BUFFER_LENGTH_MISMATCH = 0x1000, - EVENT_STREAM_INSUFFICIENT_BUFFER_LEN, - EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED, - EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE, - EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE, - EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN, - EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE, - EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE, - EVENT_STREAM_UNKNOWN_ERROR - }; - - namespace EventStreamErrorsMapper - { - /** - * Get name by its error type in event stream. - */ - AWS_CORE_API const char* GetNameForError(Event::EventStreamErrors error); - /** - * Get AWSError by EventStreamError. The Error type will always be CoreErrors::UNKNOWN as an internal error in Event Stream, and it's always not retryable. - */ - AWS_CORE_API Aws::Client::AWSError<Aws::Client::CoreErrors> GetAwsErrorForEventStreamError(Event::EventStreamErrors error); - } // namespace EventStreamErrorsMapper - } // namespace Event - } // namespace Utils -} // namespace Aws
\ No newline at end of file + */ +#pragma once + +#include <aws/core/client/CoreErrors.h> +#include <aws/core/Core_EXPORTS.h> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + /** + * Errors encountered in event stream. + * These errors are associated with those in aws-c-event-stream library. + */ + enum class EventStreamErrors + { + EVENT_STREAM_NO_ERROR = 0, + EVENT_STREAM_BUFFER_LENGTH_MISMATCH = 0x1000, + EVENT_STREAM_INSUFFICIENT_BUFFER_LEN, + EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED, + EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE, + EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE, + EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN, + EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE, + EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE, + EVENT_STREAM_UNKNOWN_ERROR + }; + + namespace EventStreamErrorsMapper + { + /** + * Get name by its error type in event stream. + */ + AWS_CORE_API const char* GetNameForError(Event::EventStreamErrors error); + /** + * Get AWSError by EventStreamError. The Error type will always be CoreErrors::UNKNOWN as an internal error in Event Stream, and it's always not retryable. + */ + AWS_CORE_API Aws::Client::AWSError<Aws::Client::CoreErrors> GetAwsErrorForEventStreamError(Event::EventStreamErrors error); + } // namespace EventStreamErrorsMapper + } // namespace Event + } // namespace Utils +} // namespace Aws
\ No newline at end of file diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h index 257bfd8288..5b86329c18 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h @@ -1,147 +1,147 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/http/HttpTypes.h> -#include <aws/core/utils/event/EventHeader.h> -#include <aws/core/utils/event/EventMessage.h> -#include <aws/core/utils/event/EventStreamErrors.h> -#include <aws/core/utils/memory/stl/AWSString.h> -#include <aws/core/utils/memory/stl/AWSStreamFwd.h> -#include <aws/core/utils/memory/stl/AWSStringStream.h> -#include <cassert> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - /** - * Handler of event stream. - * Includes context and callback function while scanning the event stream. - */ - class AWS_CORE_API EventStreamHandler - { - public: - EventStreamHandler() : - m_failure(false), m_internalError(EventStreamErrors::EVENT_STREAM_NO_ERROR), m_headersBytesReceived(0), m_payloadBytesReceived(0) - {} - - virtual ~EventStreamHandler() = default; - - /** - * Whether or not flow handler is in a good state. Return false if handler encounters errors. - */ - inline operator bool() const { return !m_failure; } - - /** - * Fail the handler from outside. - */ - inline void SetFailure() { m_failure = true; } - - /** - * Clean up current bytes of data received, as well as the latest message. - */ - inline virtual void Reset() - { - m_failure = false; - m_internalError = EventStreamErrors::EVENT_STREAM_NO_ERROR; - m_headersBytesReceived = 0; - m_payloadBytesReceived = 0; - - m_message.Reset(); - } - - /** - * Set internal Event Stream Errors, which is associated with errors in aws-c-event-stream library. - */ - inline void SetInternalError(int errorCode = 0) - { - m_internalError = static_cast<EventStreamErrors>(errorCode); - } - - /** - * Get internal Event Stream Errors. - */ - inline EventStreamErrors GetInternalError() - { - return m_internalError; - } - - /** - * The message is considered to completed with the following scenarios: - * 1. Message doesn't have headers or payloads. Or - * 2. Message has headers but doesn't have payloads. Or - * 3. Message has both headers and payloads. - */ - inline virtual bool IsMessageCompleted() - { - return m_message.GetHeadersLength() == m_headersBytesReceived && m_message.GetPayloadLength() == m_payloadBytesReceived; - } - - /** - * Set message metadata, including total message length, headers length and payload length. - */ - inline virtual void SetMessageMetadata(size_t totalLength, size_t headersLength, size_t payloadLength) - { - m_message.SetTotalLength(totalLength); - m_message.SetHeadersLength(headersLength); - m_message.SetPayloadLength(payloadLength); - assert(totalLength == 12/*prelude length*/ + headersLength + payloadLength + 4/*message crc length*/); - if (totalLength != headersLength + payloadLength + 16) - { - AWS_LOG_WARN("EventStreamHandler", "Message total length mismatch."); - } - } - - /** - * Write data to underlying stream, and update payload bytes received. - */ - inline virtual void WriteMessageEventPayload(const unsigned char* data, size_t dataLength) - { - m_message.WriteEventPayload(data, dataLength); - m_payloadBytesReceived += dataLength; - } - - /** - * Get underlying byte array of the message just received. - */ - inline virtual Aws::Vector<unsigned char>&& GetEventPayloadWithOwnership() { return m_message.GetEventPayloadWithOwnership(); } - - /** - * Convert underlying byte array to string without transferring ownership. - */ - inline virtual Aws::String GetEventPayloadAsString() { return m_message.GetEventPayloadAsString(); } - - /** - * Insert event header to a underlying event header value map, and update headers bytes received. - */ - inline virtual void InsertMessageEventHeader(const String& eventHeaderName, size_t eventHeaderLength, const Aws::Utils::Event::EventHeaderValue& eventHeaderValue) - { - m_message.InsertEventHeader(eventHeaderName, eventHeaderValue); - m_headersBytesReceived += eventHeaderLength; - } - - inline virtual const Aws::Utils::Event::EventHeaderValueCollection& GetEventHeaders() { return m_message.GetEventHeaders(); } - - /** - * Entry point of all callback functions. - * Will trigger associated functions based on m_message. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/http/HttpTypes.h> +#include <aws/core/utils/event/EventHeader.h> +#include <aws/core/utils/event/EventMessage.h> +#include <aws/core/utils/event/EventStreamErrors.h> +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSStreamFwd.h> +#include <aws/core/utils/memory/stl/AWSStringStream.h> +#include <cassert> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + /** + * Handler of event stream. + * Includes context and callback function while scanning the event stream. + */ + class AWS_CORE_API EventStreamHandler + { + public: + EventStreamHandler() : + m_failure(false), m_internalError(EventStreamErrors::EVENT_STREAM_NO_ERROR), m_headersBytesReceived(0), m_payloadBytesReceived(0) + {} + + virtual ~EventStreamHandler() = default; + + /** + * Whether or not flow handler is in a good state. Return false if handler encounters errors. */ - virtual void OnEvent() = 0; - - private: - bool m_failure; - EventStreamErrors m_internalError; - size_t m_headersBytesReceived; - size_t m_payloadBytesReceived; - Aws::Utils::Event::Message m_message; - }; - } - } + inline operator bool() const { return !m_failure; } + + /** + * Fail the handler from outside. + */ + inline void SetFailure() { m_failure = true; } + + /** + * Clean up current bytes of data received, as well as the latest message. + */ + inline virtual void Reset() + { + m_failure = false; + m_internalError = EventStreamErrors::EVENT_STREAM_NO_ERROR; + m_headersBytesReceived = 0; + m_payloadBytesReceived = 0; + + m_message.Reset(); + } + + /** + * Set internal Event Stream Errors, which is associated with errors in aws-c-event-stream library. + */ + inline void SetInternalError(int errorCode = 0) + { + m_internalError = static_cast<EventStreamErrors>(errorCode); + } + + /** + * Get internal Event Stream Errors. + */ + inline EventStreamErrors GetInternalError() + { + return m_internalError; + } + + /** + * The message is considered to completed with the following scenarios: + * 1. Message doesn't have headers or payloads. Or + * 2. Message has headers but doesn't have payloads. Or + * 3. Message has both headers and payloads. + */ + inline virtual bool IsMessageCompleted() + { + return m_message.GetHeadersLength() == m_headersBytesReceived && m_message.GetPayloadLength() == m_payloadBytesReceived; + } + + /** + * Set message metadata, including total message length, headers length and payload length. + */ + inline virtual void SetMessageMetadata(size_t totalLength, size_t headersLength, size_t payloadLength) + { + m_message.SetTotalLength(totalLength); + m_message.SetHeadersLength(headersLength); + m_message.SetPayloadLength(payloadLength); + assert(totalLength == 12/*prelude length*/ + headersLength + payloadLength + 4/*message crc length*/); + if (totalLength != headersLength + payloadLength + 16) + { + AWS_LOG_WARN("EventStreamHandler", "Message total length mismatch."); + } + } + + /** + * Write data to underlying stream, and update payload bytes received. + */ + inline virtual void WriteMessageEventPayload(const unsigned char* data, size_t dataLength) + { + m_message.WriteEventPayload(data, dataLength); + m_payloadBytesReceived += dataLength; + } + + /** + * Get underlying byte array of the message just received. + */ + inline virtual Aws::Vector<unsigned char>&& GetEventPayloadWithOwnership() { return m_message.GetEventPayloadWithOwnership(); } + + /** + * Convert underlying byte array to string without transferring ownership. + */ + inline virtual Aws::String GetEventPayloadAsString() { return m_message.GetEventPayloadAsString(); } + + /** + * Insert event header to a underlying event header value map, and update headers bytes received. + */ + inline virtual void InsertMessageEventHeader(const String& eventHeaderName, size_t eventHeaderLength, const Aws::Utils::Event::EventHeaderValue& eventHeaderValue) + { + m_message.InsertEventHeader(eventHeaderName, eventHeaderValue); + m_headersBytesReceived += eventHeaderLength; + } + + inline virtual const Aws::Utils::Event::EventHeaderValueCollection& GetEventHeaders() { return m_message.GetEventHeaders(); } + + /** + * Entry point of all callback functions. + * Will trigger associated functions based on m_message. + */ + virtual void OnEvent() = 0; + + private: + bool m_failure; + EventStreamErrors m_internalError; + size_t m_headersBytesReceived; + size_t m_payloadBytesReceived; + Aws::Utils::Event::Message m_message; + }; + } + } } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/SimpleStringStream.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/SimpleStringStream.h index 45c4d0a448..867fe67d0a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/SimpleStringStream.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/SimpleStringStream.h @@ -42,7 +42,7 @@ class AWS_CORE_API SimpleStringStream : public std::iostream Aws::Utils::Stream::SimpleStreamBuf* rdbuf() const { return const_cast<Aws::Utils::Stream::SimpleStreamBuf*>(&m_streamBuffer); } - Aws::String str() const { return m_streamBuffer.str(); } + Aws::String str() const { return m_streamBuffer.str(); } void str(const Aws::String& value); private: @@ -78,7 +78,7 @@ class AWS_CORE_API SimpleIStringStream : public std::istream Aws::Utils::Stream::SimpleStreamBuf* rdbuf() const { return const_cast<Aws::Utils::Stream::SimpleStreamBuf*>(&m_streamBuffer); } - Aws::String str() const { return m_streamBuffer.str(); } + Aws::String str() const { return m_streamBuffer.str(); } void str(const Aws::String& value); private: @@ -114,7 +114,7 @@ class AWS_CORE_API SimpleOStringStream : public std::ostream Aws::Utils::Stream::SimpleStreamBuf* rdbuf() const { return const_cast<Aws::Utils::Stream::SimpleStreamBuf*>(&m_streamBuffer); } - Aws::String str() const { return m_streamBuffer.str(); } + Aws::String str() const { return m_streamBuffer.str(); } void str(const Aws::String& value); private: diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ConcurrentStreamBuf.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ConcurrentStreamBuf.h index 9ef7d9763e..d30ca478a9 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ConcurrentStreamBuf.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ConcurrentStreamBuf.h @@ -1,58 +1,58 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#pragma once - -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/auth/AWSAuthSigner.h> -#include <aws/common/array_list.h> - -#include <mutex> -#include <condition_variable> -#include <streambuf> -#include <ios> -#include <cassert> - -namespace Aws -{ - namespace Utils - { - namespace Stream - { - /** - * A thread-safe streambuf implementation that allows simultaneous reading and writing. - * NOTE: iostreams maintain state for readers and writers. This means that you can have at most two - * concurrent threads, one for reading and one for writing. Multiple readers or multiple writers are not - * thread-safe and will result in race-conditions. - */ - class AWS_CORE_API ConcurrentStreamBuf : public std::streambuf - { - public: - - explicit ConcurrentStreamBuf(size_t bufferLength = 4 * 1024); - - void SetEof(); - - protected: - std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; - std::streampos seekpos(std::streampos pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; - - int underflow() override; - int overflow(int ch) override; - int sync() override; - std::streamsize showmanyc() override; - - void FlushPutArea(); - - private: - Aws::Vector<unsigned char> m_getArea; - Aws::Vector<unsigned char> m_putArea; - Aws::Vector<unsigned char> m_backbuf; // used to shuttle data from the put area to the get area - std::mutex m_lock; // synchronize access to the common backbuffer - std::condition_variable m_signal; - bool m_eof; - }; - } - } -} + */ +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/auth/AWSAuthSigner.h> +#include <aws/common/array_list.h> + +#include <mutex> +#include <condition_variable> +#include <streambuf> +#include <ios> +#include <cassert> + +namespace Aws +{ + namespace Utils + { + namespace Stream + { + /** + * A thread-safe streambuf implementation that allows simultaneous reading and writing. + * NOTE: iostreams maintain state for readers and writers. This means that you can have at most two + * concurrent threads, one for reading and one for writing. Multiple readers or multiple writers are not + * thread-safe and will result in race-conditions. + */ + class AWS_CORE_API ConcurrentStreamBuf : public std::streambuf + { + public: + + explicit ConcurrentStreamBuf(size_t bufferLength = 4 * 1024); + + void SetEof(); + + protected: + std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; + std::streampos seekpos(std::streampos pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; + + int underflow() override; + int overflow(int ch) override; + int sync() override; + std::streamsize showmanyc() override; + + void FlushPutArea(); + + private: + Aws::Vector<unsigned char> m_getArea; + Aws::Vector<unsigned char> m_putArea; + Aws::Vector<unsigned char> m_backbuf; // used to shuttle data from the put area to the get area + std::mutex m_lock; // synchronize access to the common backbuffer + std::condition_variable m_signal; + bool m_eof; + }; + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/PreallocatedStreamBuf.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/PreallocatedStreamBuf.h index ad9dc2a929..4e5bc0f6df 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/PreallocatedStreamBuf.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/PreallocatedStreamBuf.h @@ -41,14 +41,14 @@ namespace Aws * Get the buffer that is being used by the stream buffer. * @return Pointer to the underlying buffer (probably for a Aws::Delete() call). */ - unsigned char* GetBuffer() { return m_underlyingBuffer; } + unsigned char* GetBuffer() { return m_underlyingBuffer; } protected: pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; pos_type seekpos(pos_type pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override; private: - unsigned char* m_underlyingBuffer; + unsigned char* m_underlyingBuffer; const uint64_t m_lengthToRead; }; } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/SimpleStreamBuf.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/SimpleStreamBuf.h index ef12c60ba3..ce0458b719 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/SimpleStreamBuf.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/SimpleStreamBuf.h @@ -37,7 +37,7 @@ namespace Stream virtual ~SimpleStreamBuf(); - Aws::String str() const; + Aws::String str() const; void str(const Aws::String& value); void swap(SimpleStreamBuf& rhs); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/Aws.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/Aws.cpp index 1eaa477fca..54a55e1118 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/Aws.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/Aws.cpp @@ -5,7 +5,7 @@ #include <aws/core/Version.h> #include <aws/core/utils/logging/LogMacros.h> #include <aws/core/Aws.h> -#include <aws/core/client/CoreErrors.h> +#include <aws/core/client/CoreErrors.h> #include <aws/core/utils/logging/AWSLogging.h> #include <aws/core/utils/logging/DefaultLogSystem.h> #include <aws/core/Globals.h> @@ -27,7 +27,7 @@ namespace Aws Aws::Utils::Memory::InitializeAWSMemorySystem(*options.memoryManagementOptions.memoryManager); } #endif // USE_AWS_MEMORY_MANAGEMENT - Aws::Client::CoreErrorsMapper::InitCoreErrorsMapper(); + Aws::Client::CoreErrorsMapper::InitCoreErrorsMapper(); if(options.loggingOptions.logLevel != Aws::Utils::Logging::LogLevel::Off) { if(options.loggingOptions.logger_create_fn) @@ -122,7 +122,7 @@ namespace Aws Aws::Utils::Logging::ShutdownAWSLogging(); } - Aws::Client::CoreErrorsMapper::CleanupCoreErrorsMapper(); + Aws::Client::CoreErrorsMapper::CleanupCoreErrorsMapper(); #ifdef USE_AWS_MEMORY_MANAGEMENT if(options.memoryManagementOptions.memoryManager) diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSAuthSigner.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSAuthSigner.cpp index de4826fa5b..f6a0d5da71 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSAuthSigner.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSAuthSigner.cpp @@ -17,14 +17,14 @@ #include <aws/core/utils/memory/AWSMemory.h> #include <aws/core/utils/crypto/Sha256.h> #include <aws/core/utils/crypto/Sha256HMAC.h> -#include <aws/core/utils/stream/PreallocatedStreamBuf.h> -#include <aws/core/utils/event/EventMessage.h> -#include <aws/core/utils/event/EventHeader.h> +#include <aws/core/utils/stream/PreallocatedStreamBuf.h> +#include <aws/core/utils/event/EventMessage.h> +#include <aws/core/utils/event/EventHeader.h> #include <cstdio> #include <iomanip> #include <math.h> -#include <cstring> +#include <cstring> using namespace Aws; using namespace Aws::Client; @@ -35,8 +35,8 @@ using namespace Aws::Utils::Logging; static const char* EQ = "="; static const char* AWS_HMAC_SHA256 = "AWS4-HMAC-SHA256"; -static const char* EVENT_STREAM_CONTENT_SHA256 = "STREAMING-AWS4-HMAC-SHA256-EVENTS"; -static const char* EVENT_STREAM_PAYLOAD = "AWS4-HMAC-SHA256-PAYLOAD"; +static const char* EVENT_STREAM_CONTENT_SHA256 = "STREAMING-AWS4-HMAC-SHA256-EVENTS"; +static const char* EVENT_STREAM_PAYLOAD = "AWS4-HMAC-SHA256-PAYLOAD"; static const char* AWS4_REQUEST = "aws4_request"; static const char* SIGNED_HEADERS = "SignedHeaders"; static const char* CREDENTIAL = "Credential"; @@ -46,25 +46,25 @@ static const char* X_AMZ_ALGORITHM = "X-Amz-Algorithm"; static const char* X_AMZ_CREDENTIAL = "X-Amz-Credential"; static const char* UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD"; static const char* X_AMZ_SIGNATURE = "X-Amz-Signature"; -static const char* X_AMZN_TRACE_ID = "x-amzn-trace-id"; -static const char* X_AMZ_CONTENT_SHA256 = "x-amz-content-sha256"; -static const char* USER_AGENT = "user-agent"; +static const char* X_AMZN_TRACE_ID = "x-amzn-trace-id"; +static const char* X_AMZ_CONTENT_SHA256 = "x-amz-content-sha256"; +static const char* USER_AGENT = "user-agent"; static const char* SIGNING_KEY = "AWS4"; static const char* SIMPLE_DATE_FORMAT_STR = "%Y%m%d"; static const char* EMPTY_STRING_SHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; -static const char v4LogTag[] = "AWSAuthV4Signer"; -static const char v4StreamingLogTag[] = "AWSAuthEventStreamV4Signer"; +static const char v4LogTag[] = "AWSAuthV4Signer"; +static const char v4StreamingLogTag[] = "AWSAuthEventStreamV4Signer"; namespace Aws { namespace Auth { - const char SIGNATURE[] = "Signature"; + const char SIGNATURE[] = "Signature"; const char SIGV4_SIGNER[] = "SignatureV4"; - const char EVENTSTREAM_SIGV4_SIGNER[] = "EventStreamSignatureV4"; - const char EVENTSTREAM_SIGNATURE_HEADER[] = ":chunk-signature"; - const char EVENTSTREAM_DATE_HEADER[] = ":date"; + const char EVENTSTREAM_SIGV4_SIGNER[] = "EventStreamSignatureV4"; + const char EVENTSTREAM_SIGNATURE_HEADER[] = ":chunk-signature"; + const char EVENTSTREAM_DATE_HEADER[] = ":date"; const char NULL_SIGNER[] = "NullSigner"; } } @@ -152,7 +152,7 @@ AWSAuthV4Signer::AWSAuthV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvi m_region(region), m_hash(Aws::MakeUnique<Aws::Utils::Crypto::Sha256>(v4LogTag)), m_HMAC(Aws::MakeUnique<Aws::Utils::Crypto::Sha256HMAC>(v4LogTag)), - m_unsignedHeaders({USER_AGENT, X_AMZN_TRACE_ID}), + m_unsignedHeaders({USER_AGENT, X_AMZN_TRACE_ID}), m_payloadSigningPolicy(signingPolicy), m_urlEscapePath(urlEscapePath) { @@ -203,7 +203,7 @@ bool AWSAuthV4Signer::SignRequest(Aws::Http::HttpRequest& request, const char* r if(signBody || request.GetUri().GetScheme() != Http::Scheme::HTTPS) { - payloadHash = ComputePayloadHash(request); + payloadHash = ComputePayloadHash(request); if (payloadHash.empty()) { return false; @@ -217,7 +217,7 @@ bool AWSAuthV4Signer::SignRequest(Aws::Http::HttpRequest& request, const char* r if(m_includeSha256HashHeader) { - request.SetHeaderValue(X_AMZ_CONTENT_SHA256, payloadHash); + request.SetHeaderValue(X_AMZ_CONTENT_SHA256, payloadHash); } //calculate date header to use in internal signature (this also goes into date header). @@ -245,7 +245,7 @@ bool AWSAuthV4Signer::SignRequest(Aws::Http::HttpRequest& request, const char* r //remove that last semi-colon if (!signedHeadersValue.empty()) { - signedHeadersValue.pop_back(); + signedHeadersValue.pop_back(); } AWS_LOGSTREAM_DEBUG(v4LogTag, "Signed Headers value:" << signedHeadersValue); @@ -375,11 +375,11 @@ bool AWSAuthV4Signer::PresignRequest(Aws::Http::HttpRequest& request, const char canonicalRequestString.append(signedHeadersValue); canonicalRequestString.append(NEWLINE); if (ServiceRequireUnsignedPayload(signingServiceName)) - { + { canonicalRequestString.append(UNSIGNED_PAYLOAD); - } - else - { + } + else + { canonicalRequestString.append(EMPTY_STRING_SHA256); } AWS_LOGSTREAM_DEBUG(v4LogTag, "Canonical Request String: " << canonicalRequestString); @@ -438,7 +438,7 @@ Aws::String AWSAuthV4Signer::GenerateSignature(const Aws::String& stringToSign, { AWS_LOGSTREAM_ERROR(v4LogTag, "Unable to hmac (sha256) final string"); AWS_LOGSTREAM_DEBUG(v4LogTag, "The final string is: \"" << stringToSign << "\""); - return {}; + return {}; } //now we finally sign our request string with our hex encoded derived hash. @@ -470,7 +470,7 @@ Aws::String AWSAuthV4Signer::ComputePayloadHash(Aws::Http::HttpRequest& request) if (!hashResult.IsSuccess()) { AWS_LOGSTREAM_ERROR(v4LogTag, "Unable to hash (sha256) request body"); - return {}; + return {}; } auto sha256Digest = hashResult.GetResult(); @@ -532,275 +532,275 @@ Aws::Utils::ByteBuffer AWSAuthV4Signer::ComputeHash(const Aws::String& secretKey } return hashResult.GetResult(); } - -AWSAuthEventStreamV4Signer::AWSAuthEventStreamV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& - credentialsProvider, const char* serviceName, const Aws::String& region) : - m_serviceName(serviceName), - m_region(region), - m_credentialsProvider(credentialsProvider) -{ - - m_unsignedHeaders.emplace_back(X_AMZN_TRACE_ID); - m_unsignedHeaders.emplace_back(USER_AGENT_HEADER); -} - + +AWSAuthEventStreamV4Signer::AWSAuthEventStreamV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& + credentialsProvider, const char* serviceName, const Aws::String& region) : + m_serviceName(serviceName), + m_region(region), + m_credentialsProvider(credentialsProvider) +{ + + m_unsignedHeaders.emplace_back(X_AMZN_TRACE_ID); + m_unsignedHeaders.emplace_back(USER_AGENT_HEADER); +} + bool AWSAuthEventStreamV4Signer::SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool /* signBody */) const -{ - AWSCredentials credentials = m_credentialsProvider->GetAWSCredentials(); - - //don't sign anonymous requests - if (credentials.GetAWSAccessKeyId().empty() || credentials.GetAWSSecretKey().empty()) - { - return true; - } - - if (!credentials.GetSessionToken().empty()) - { - request.SetAwsSessionToken(credentials.GetSessionToken()); - } - - request.SetHeaderValue(X_AMZ_CONTENT_SHA256, EVENT_STREAM_CONTENT_SHA256); - - //calculate date header to use in internal signature (this also goes into date header). - DateTime now = GetSigningTimestamp(); +{ + AWSCredentials credentials = m_credentialsProvider->GetAWSCredentials(); + + //don't sign anonymous requests + if (credentials.GetAWSAccessKeyId().empty() || credentials.GetAWSSecretKey().empty()) + { + return true; + } + + if (!credentials.GetSessionToken().empty()) + { + request.SetAwsSessionToken(credentials.GetSessionToken()); + } + + request.SetHeaderValue(X_AMZ_CONTENT_SHA256, EVENT_STREAM_CONTENT_SHA256); + + //calculate date header to use in internal signature (this also goes into date header). + DateTime now = GetSigningTimestamp(); Aws::String dateHeaderValue = now.ToGmtString(DateFormat::ISO_8601_BASIC); - request.SetHeaderValue(AWS_DATE_HEADER, dateHeaderValue); - - Aws::StringStream headersStream; - Aws::StringStream signedHeadersStream; - - for (const auto& header : CanonicalizeHeaders(request.GetHeaders())) - { - if(ShouldSignHeader(header.first)) - { - headersStream << header.first.c_str() << ":" << header.second.c_str() << NEWLINE; - signedHeadersStream << header.first.c_str() << ";"; - } - } - - Aws::String canonicalHeadersString = headersStream.str(); - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Canonical Header String: " << canonicalHeadersString); - - //calculate signed headers parameter - Aws::String signedHeadersValue = signedHeadersStream.str(); - //remove that last semi-colon - if (!signedHeadersValue.empty()) - { - signedHeadersValue.pop_back(); - } - - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Signed Headers value:" << signedHeadersValue); - - //generate generalized canonicalized request string. - Aws::String canonicalRequestString = CanonicalizeRequestSigningString(request, true/* m_urlEscapePath */); - - //append v4 stuff to the canonical request string. - canonicalRequestString.append(canonicalHeadersString); - canonicalRequestString.append(NEWLINE); - canonicalRequestString.append(signedHeadersValue); - canonicalRequestString.append(NEWLINE); - canonicalRequestString.append(EVENT_STREAM_CONTENT_SHA256); - - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Canonical Request String: " << canonicalRequestString); - - //now compute sha256 on that request string - auto hashResult = m_hash.Calculate(canonicalRequestString); - if (!hashResult.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to hash (sha256) request string"); - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "The request string is: \"" << canonicalRequestString << "\""); - return false; - } - - auto sha256Digest = hashResult.GetResult(); + request.SetHeaderValue(AWS_DATE_HEADER, dateHeaderValue); + + Aws::StringStream headersStream; + Aws::StringStream signedHeadersStream; + + for (const auto& header : CanonicalizeHeaders(request.GetHeaders())) + { + if(ShouldSignHeader(header.first)) + { + headersStream << header.first.c_str() << ":" << header.second.c_str() << NEWLINE; + signedHeadersStream << header.first.c_str() << ";"; + } + } + + Aws::String canonicalHeadersString = headersStream.str(); + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Canonical Header String: " << canonicalHeadersString); + + //calculate signed headers parameter + Aws::String signedHeadersValue = signedHeadersStream.str(); + //remove that last semi-colon + if (!signedHeadersValue.empty()) + { + signedHeadersValue.pop_back(); + } + + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Signed Headers value:" << signedHeadersValue); + + //generate generalized canonicalized request string. + Aws::String canonicalRequestString = CanonicalizeRequestSigningString(request, true/* m_urlEscapePath */); + + //append v4 stuff to the canonical request string. + canonicalRequestString.append(canonicalHeadersString); + canonicalRequestString.append(NEWLINE); + canonicalRequestString.append(signedHeadersValue); + canonicalRequestString.append(NEWLINE); + canonicalRequestString.append(EVENT_STREAM_CONTENT_SHA256); + + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Canonical Request String: " << canonicalRequestString); + + //now compute sha256 on that request string + auto hashResult = m_hash.Calculate(canonicalRequestString); + if (!hashResult.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to hash (sha256) request string"); + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "The request string is: \"" << canonicalRequestString << "\""); + return false; + } + + auto sha256Digest = hashResult.GetResult(); Aws::String canonicalRequestHash = HashingUtils::HexEncode(sha256Digest); - Aws::String simpleDate = now.ToGmtString(SIMPLE_DATE_FORMAT_STR); - + Aws::String simpleDate = now.ToGmtString(SIMPLE_DATE_FORMAT_STR); + Aws::String signingRegion = region ? region : m_region; Aws::String signingServiceName = serviceName ? serviceName : m_serviceName; Aws::String stringToSign = GenerateStringToSign(dateHeaderValue, simpleDate, canonicalRequestHash, signingRegion, signingServiceName); auto finalSignature = GenerateSignature(credentials, stringToSign, simpleDate, signingRegion, signingServiceName); - - Aws::StringStream ss; - ss << AWS_HMAC_SHA256 << " " << CREDENTIAL << EQ << credentials.GetAWSAccessKeyId() << "/" << simpleDate + + Aws::StringStream ss; + ss << AWS_HMAC_SHA256 << " " << CREDENTIAL << EQ << credentials.GetAWSAccessKeyId() << "/" << simpleDate << "/" << signingRegion << "/" << signingServiceName << "/" << AWS4_REQUEST << ", " << SIGNED_HEADERS << EQ - << signedHeadersValue << ", " << SIGNATURE << EQ << HashingUtils::HexEncode(finalSignature); - - auto awsAuthString = ss.str(); - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Signing request with: " << awsAuthString); - request.SetAwsAuthorization(awsAuthString); - request.SetSigningAccessKey(credentials.GetAWSAccessKeyId()); + << signedHeadersValue << ", " << SIGNATURE << EQ << HashingUtils::HexEncode(finalSignature); + + auto awsAuthString = ss.str(); + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Signing request with: " << awsAuthString); + request.SetAwsAuthorization(awsAuthString); + request.SetSigningAccessKey(credentials.GetAWSAccessKeyId()); request.SetSigningRegion(signingRegion); - return true; -} - -// this works regardless if the current machine is Big/Little Endian -static void WriteBigEndian(Aws::String& str, uint64_t n) -{ - int shift = 56; - while(shift >= 0) - { - str.push_back((n >> shift) & 0xFF); - shift -= 8; - } -} - -bool AWSAuthEventStreamV4Signer::SignEventMessage(Event::Message& message, Aws::String& priorSignature) const -{ - using Event::EventHeaderValue; - - Aws::StringStream stringToSign; - stringToSign << EVENT_STREAM_PAYLOAD << NEWLINE; - const DateTime now = GetSigningTimestamp(); - const auto simpleDate = now.ToGmtString(SIMPLE_DATE_FORMAT_STR); + return true; +} + +// this works regardless if the current machine is Big/Little Endian +static void WriteBigEndian(Aws::String& str, uint64_t n) +{ + int shift = 56; + while(shift >= 0) + { + str.push_back((n >> shift) & 0xFF); + shift -= 8; + } +} + +bool AWSAuthEventStreamV4Signer::SignEventMessage(Event::Message& message, Aws::String& priorSignature) const +{ + using Event::EventHeaderValue; + + Aws::StringStream stringToSign; + stringToSign << EVENT_STREAM_PAYLOAD << NEWLINE; + const DateTime now = GetSigningTimestamp(); + const auto simpleDate = now.ToGmtString(SIMPLE_DATE_FORMAT_STR); stringToSign << now.ToGmtString(DateFormat::ISO_8601_BASIC) << NEWLINE - << simpleDate << "/" << m_region << "/" - << m_serviceName << "/aws4_request" << NEWLINE << priorSignature << NEWLINE; - - - Aws::String nonSignatureHeaders; - nonSignatureHeaders.push_back(char(sizeof(EVENTSTREAM_DATE_HEADER) - 1)); // length of the string - nonSignatureHeaders += EVENTSTREAM_DATE_HEADER; - nonSignatureHeaders.push_back(static_cast<char>(EventHeaderValue::EventHeaderType::TIMESTAMP)); // type of the value - WriteBigEndian(nonSignatureHeaders, static_cast<uint64_t>(now.Millis())); // the value of the timestamp in big-endian - - auto hashOutcome = m_hash.Calculate(nonSignatureHeaders); - if (!hashOutcome.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to hash (sha256) non-signature headers."); - return false; - } - - const auto nonSignatureHeadersHash = hashOutcome.GetResult(); - stringToSign << HashingUtils::HexEncode(nonSignatureHeadersHash) << NEWLINE; - - if (message.GetEventPayload().empty()) - { - AWS_LOGSTREAM_WARN(v4StreamingLogTag, "Attempting to sign an empty message (no payload and no headers). " - "It is unlikely that this is the intended behavior."); - } - else - { - // use a preallocatedStreamBuf to avoid making a copy. - // The Hashing API requires either Aws::String or IStream as input. - // TODO: the hashing API should be accept 'unsigned char*' as input. - Utils::Stream::PreallocatedStreamBuf streamBuf(message.GetEventPayload().data(), message.GetEventPayload().size()); - Aws::IOStream payload(&streamBuf); - hashOutcome = m_hash.Calculate(payload); - - if (!hashOutcome.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to hash (sha256) non-signature headers."); - return false; - } - const auto payloadHash = hashOutcome.GetResult(); - stringToSign << HashingUtils::HexEncode(payloadHash); - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Payload hash - " << HashingUtils::HexEncode(payloadHash)); - } - + << simpleDate << "/" << m_region << "/" + << m_serviceName << "/aws4_request" << NEWLINE << priorSignature << NEWLINE; + + + Aws::String nonSignatureHeaders; + nonSignatureHeaders.push_back(char(sizeof(EVENTSTREAM_DATE_HEADER) - 1)); // length of the string + nonSignatureHeaders += EVENTSTREAM_DATE_HEADER; + nonSignatureHeaders.push_back(static_cast<char>(EventHeaderValue::EventHeaderType::TIMESTAMP)); // type of the value + WriteBigEndian(nonSignatureHeaders, static_cast<uint64_t>(now.Millis())); // the value of the timestamp in big-endian + + auto hashOutcome = m_hash.Calculate(nonSignatureHeaders); + if (!hashOutcome.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to hash (sha256) non-signature headers."); + return false; + } + + const auto nonSignatureHeadersHash = hashOutcome.GetResult(); + stringToSign << HashingUtils::HexEncode(nonSignatureHeadersHash) << NEWLINE; + + if (message.GetEventPayload().empty()) + { + AWS_LOGSTREAM_WARN(v4StreamingLogTag, "Attempting to sign an empty message (no payload and no headers). " + "It is unlikely that this is the intended behavior."); + } + else + { + // use a preallocatedStreamBuf to avoid making a copy. + // The Hashing API requires either Aws::String or IStream as input. + // TODO: the hashing API should be accept 'unsigned char*' as input. + Utils::Stream::PreallocatedStreamBuf streamBuf(message.GetEventPayload().data(), message.GetEventPayload().size()); + Aws::IOStream payload(&streamBuf); + hashOutcome = m_hash.Calculate(payload); + + if (!hashOutcome.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to hash (sha256) non-signature headers."); + return false; + } + const auto payloadHash = hashOutcome.GetResult(); + stringToSign << HashingUtils::HexEncode(payloadHash); + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Payload hash - " << HashingUtils::HexEncode(payloadHash)); + } + Utils::ByteBuffer finalSignatureDigest = GenerateSignature(m_credentialsProvider->GetAWSCredentials(), stringToSign.str(), simpleDate, m_region, m_serviceName); - const auto finalSignature = HashingUtils::HexEncode(finalSignatureDigest); - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Final computed signing hash: " << finalSignature); - priorSignature = finalSignature; - - message.InsertEventHeader(EVENTSTREAM_DATE_HEADER, EventHeaderValue(now.Millis(), EventHeaderValue::EventHeaderType::TIMESTAMP)); - message.InsertEventHeader(EVENTSTREAM_SIGNATURE_HEADER, std::move(finalSignatureDigest)); - - AWS_LOGSTREAM_INFO(v4StreamingLogTag, "Event chunk final signature - " << finalSignature); - return true; -} - -bool AWSAuthEventStreamV4Signer::ShouldSignHeader(const Aws::String& header) const -{ - return std::find(m_unsignedHeaders.cbegin(), m_unsignedHeaders.cend(), Aws::Utils::StringUtils::ToLower(header.c_str())) == m_unsignedHeaders.cend(); -} - -Utils::ByteBuffer AWSAuthEventStreamV4Signer::GenerateSignature(const AWSCredentials& credentials, const Aws::String& stringToSign, + const auto finalSignature = HashingUtils::HexEncode(finalSignatureDigest); + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Final computed signing hash: " << finalSignature); + priorSignature = finalSignature; + + message.InsertEventHeader(EVENTSTREAM_DATE_HEADER, EventHeaderValue(now.Millis(), EventHeaderValue::EventHeaderType::TIMESTAMP)); + message.InsertEventHeader(EVENTSTREAM_SIGNATURE_HEADER, std::move(finalSignatureDigest)); + + AWS_LOGSTREAM_INFO(v4StreamingLogTag, "Event chunk final signature - " << finalSignature); + return true; +} + +bool AWSAuthEventStreamV4Signer::ShouldSignHeader(const Aws::String& header) const +{ + return std::find(m_unsignedHeaders.cbegin(), m_unsignedHeaders.cend(), Aws::Utils::StringUtils::ToLower(header.c_str())) == m_unsignedHeaders.cend(); +} + +Utils::ByteBuffer AWSAuthEventStreamV4Signer::GenerateSignature(const AWSCredentials& credentials, const Aws::String& stringToSign, const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const -{ - Utils::Threading::ReaderLockGuard guard(m_derivedKeyLock); - const auto& secretKey = credentials.GetAWSSecretKey(); - if (secretKey != m_currentSecretKey || simpleDate != m_currentDateStr) - { - guard.UpgradeToWriterLock(); - // double-checked lock to prevent updating twice - if (m_currentDateStr != simpleDate || m_currentSecretKey != secretKey) - { - m_currentSecretKey = secretKey; - m_currentDateStr = simpleDate; +{ + Utils::Threading::ReaderLockGuard guard(m_derivedKeyLock); + const auto& secretKey = credentials.GetAWSSecretKey(); + if (secretKey != m_currentSecretKey || simpleDate != m_currentDateStr) + { + guard.UpgradeToWriterLock(); + // double-checked lock to prevent updating twice + if (m_currentDateStr != simpleDate || m_currentSecretKey != secretKey) + { + m_currentSecretKey = secretKey; + m_currentDateStr = simpleDate; m_derivedKey = ComputeHash(m_currentSecretKey, m_currentDateStr, region, serviceName); - } - - } - return GenerateSignature(stringToSign, m_derivedKey); -} - -Utils::ByteBuffer AWSAuthEventStreamV4Signer::GenerateSignature(const Aws::String& stringToSign, const ByteBuffer& key) const -{ - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Final String to sign: " << stringToSign); - - Aws::StringStream ss; - - auto hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)stringToSign.c_str(), stringToSign.length()), key); - if (!hashResult.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Unable to hmac (sha256) final string"); - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "The final string is: \"" << stringToSign << "\""); - return {}; - } - - return hashResult.GetResult(); -} - -Aws::String AWSAuthEventStreamV4Signer::GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, - const Aws::String& canonicalRequestHash, const Aws::String& region, const Aws::String& serviceName) const -{ - //generate the actual string we will use in signing the final request. - Aws::StringStream ss; - - ss << AWS_HMAC_SHA256 << NEWLINE << dateValue << NEWLINE << simpleDate << "/" << region << "/" - << serviceName << "/" << AWS4_REQUEST << NEWLINE << canonicalRequestHash; - - return ss.str(); -} - -Aws::Utils::ByteBuffer AWSAuthEventStreamV4Signer::ComputeHash(const Aws::String& secretKey, - const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const -{ - Aws::String signingKey(SIGNING_KEY); - signingKey.append(secretKey); - auto hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)simpleDate.c_str(), simpleDate.length()), - ByteBuffer((unsigned char*)signingKey.c_str(), signingKey.length())); - - if (!hashResult.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to HMAC (SHA256) date string \"" << simpleDate << "\""); - return {}; - } - - auto kDate = hashResult.GetResult(); - hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)region.c_str(), region.length()), kDate); - if (!hashResult.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to HMAC (SHA256) region string \"" << region << "\""); - return {}; - } - - auto kRegion = hashResult.GetResult(); - hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)serviceName.c_str(), serviceName.length()), kRegion); - if (!hashResult.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to HMAC (SHA256) service string \"" << m_serviceName << "\""); - return {}; - } - - auto kService = hashResult.GetResult(); - hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)AWS4_REQUEST, strlen(AWS4_REQUEST)), kService); - if (!hashResult.IsSuccess()) - { - AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Unable to HMAC (SHA256) request string"); - AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "The request string is: \"" << AWS4_REQUEST << "\""); - return {}; - } - return hashResult.GetResult(); -} + } + + } + return GenerateSignature(stringToSign, m_derivedKey); +} + +Utils::ByteBuffer AWSAuthEventStreamV4Signer::GenerateSignature(const Aws::String& stringToSign, const ByteBuffer& key) const +{ + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "Final String to sign: " << stringToSign); + + Aws::StringStream ss; + + auto hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)stringToSign.c_str(), stringToSign.length()), key); + if (!hashResult.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Unable to hmac (sha256) final string"); + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "The final string is: \"" << stringToSign << "\""); + return {}; + } + + return hashResult.GetResult(); +} + +Aws::String AWSAuthEventStreamV4Signer::GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, + const Aws::String& canonicalRequestHash, const Aws::String& region, const Aws::String& serviceName) const +{ + //generate the actual string we will use in signing the final request. + Aws::StringStream ss; + + ss << AWS_HMAC_SHA256 << NEWLINE << dateValue << NEWLINE << simpleDate << "/" << region << "/" + << serviceName << "/" << AWS4_REQUEST << NEWLINE << canonicalRequestHash; + + return ss.str(); +} + +Aws::Utils::ByteBuffer AWSAuthEventStreamV4Signer::ComputeHash(const Aws::String& secretKey, + const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const +{ + Aws::String signingKey(SIGNING_KEY); + signingKey.append(secretKey); + auto hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)simpleDate.c_str(), simpleDate.length()), + ByteBuffer((unsigned char*)signingKey.c_str(), signingKey.length())); + + if (!hashResult.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to HMAC (SHA256) date string \"" << simpleDate << "\""); + return {}; + } + + auto kDate = hashResult.GetResult(); + hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)region.c_str(), region.length()), kDate); + if (!hashResult.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to HMAC (SHA256) region string \"" << region << "\""); + return {}; + } + + auto kRegion = hashResult.GetResult(); + hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)serviceName.c_str(), serviceName.length()), kRegion); + if (!hashResult.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Failed to HMAC (SHA256) service string \"" << m_serviceName << "\""); + return {}; + } + + auto kService = hashResult.GetResult(); + hashResult = m_HMAC.Calculate(ByteBuffer((unsigned char*)AWS4_REQUEST, strlen(AWS4_REQUEST)), kService); + if (!hashResult.IsSuccess()) + { + AWS_LOGSTREAM_ERROR(v4StreamingLogTag, "Unable to HMAC (SHA256) request string"); + AWS_LOGSTREAM_DEBUG(v4StreamingLogTag, "The request string is: \"" << AWS4_REQUEST << "\""); + return {}; + } + return hashResult.GetResult(); +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSCredentialsProvider.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSCredentialsProvider.cpp index 31e28b996f..d26d7ab006 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSCredentialsProvider.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/AWSCredentialsProvider.cpp @@ -9,7 +9,7 @@ #include <aws/core/config/AWSProfileConfigLoader.h> #include <aws/core/platform/Environment.h> #include <aws/core/platform/FileSystem.h> -#include <aws/core/platform/OSVersionInfo.h> +#include <aws/core/platform/OSVersionInfo.h> #include <aws/core/utils/logging/LogMacros.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/json/JsonSerializer.h> @@ -27,7 +27,7 @@ using namespace Aws::Utils; using namespace Aws::Utils::Logging; using namespace Aws::Auth; using namespace Aws::Internal; -using namespace Aws::FileSystem; +using namespace Aws::FileSystem; using namespace Aws::Utils::Xml; using namespace Aws::Client; using Aws::Utils::Threading::ReaderLockGuard; @@ -40,11 +40,11 @@ static const char DEFAULT_PROFILE[] = "default"; static const char AWS_PROFILE_ENV_VAR[] = "AWS_PROFILE"; static const char AWS_PROFILE_DEFAULT_ENV_VAR[] = "AWS_DEFAULT_PROFILE"; -static const char AWS_CREDENTIALS_FILE[] = "AWS_SHARED_CREDENTIALS_FILE"; +static const char AWS_CREDENTIALS_FILE[] = "AWS_SHARED_CREDENTIALS_FILE"; extern const char AWS_CONFIG_FILE[] = "AWS_CONFIG_FILE"; extern const char PROFILE_DIRECTORY[] = ".aws"; -static const char DEFAULT_CREDENTIALS_FILE[] = "credentials"; +static const char DEFAULT_CREDENTIALS_FILE[] = "credentials"; extern const char DEFAULT_CONFIG_FILE[] = "config"; @@ -98,17 +98,17 @@ AWSCredentials EnvironmentAWSCredentialsProvider::GetAWSCredentials() return credentials; } -Aws::String Aws::Auth::GetConfigProfileFilename() +Aws::String Aws::Auth::GetConfigProfileFilename() { - auto configFileNameFromVar = Aws::Environment::GetEnv(AWS_CONFIG_FILE); - if (!configFileNameFromVar.empty()) - { - return configFileNameFromVar; - } - else - { + auto configFileNameFromVar = Aws::Environment::GetEnv(AWS_CONFIG_FILE); + if (!configFileNameFromVar.empty()) + { + return configFileNameFromVar; + } + else + { return Aws::FileSystem::GetHomeDirectory() + PROFILE_DIRECTORY + PATH_DELIM + DEFAULT_CONFIG_FILE; - } + } } Aws::String Aws::Auth::GetConfigProfileName() @@ -129,11 +129,11 @@ Aws::String Aws::Auth::GetConfigProfileName() } } -static const char* PROFILE_LOG_TAG = "ProfileConfigFileAWSCredentialsProvider"; +static const char* PROFILE_LOG_TAG = "ProfileConfigFileAWSCredentialsProvider"; Aws::String ProfileConfigFileAWSCredentialsProvider::GetCredentialsProfileFilename() { - auto credentialsFileNameFromVar = Aws::Environment::GetEnv(AWS_CREDENTIALS_FILE); + auto credentialsFileNameFromVar = Aws::Environment::GetEnv(AWS_CREDENTIALS_FILE); if (credentialsFileNameFromVar.empty()) { @@ -147,15 +147,15 @@ Aws::String ProfileConfigFileAWSCredentialsProvider::GetCredentialsProfileFilena Aws::String ProfileConfigFileAWSCredentialsProvider::GetProfileDirectory() { - Aws::String credentialsFileName = GetCredentialsProfileFilename(); - auto lastSeparator = credentialsFileName.find_last_of(PATH_DELIM); + Aws::String credentialsFileName = GetCredentialsProfileFilename(); + auto lastSeparator = credentialsFileName.find_last_of(PATH_DELIM); if (lastSeparator != std::string::npos) { - return credentialsFileName.substr(0, lastSeparator); + return credentialsFileName.substr(0, lastSeparator); } else { - return {}; + return {}; } } @@ -183,9 +183,9 @@ AWSCredentials ProfileConfigFileAWSCredentialsProvider::GetAWSCredentials() { RefreshIfExpired(); ReaderLockGuard guard(m_reloadLock); - auto credsFileProfileIter = m_credentialsFileLoader.GetProfiles().find(m_profileToUse); + auto credsFileProfileIter = m_credentialsFileLoader.GetProfiles().find(m_profileToUse); - if(credsFileProfileIter != m_credentialsFileLoader.GetProfiles().end()) + if(credsFileProfileIter != m_credentialsFileLoader.GetProfiles().end()) { return credsFileProfileIter->second.GetCredentials(); } @@ -355,37 +355,37 @@ void TaskRoleCredentialsProvider::RefreshIfExpired() Reload(); } - -static const char PROCESS_LOG_TAG[] = "ProcessCredentialsProvider"; -ProcessCredentialsProvider::ProcessCredentialsProvider() : + +static const char PROCESS_LOG_TAG[] = "ProcessCredentialsProvider"; +ProcessCredentialsProvider::ProcessCredentialsProvider() : m_profileToUse(Aws::Auth::GetConfigProfileName()) -{ - AWS_LOGSTREAM_INFO(PROCESS_LOG_TAG, "Setting process credentials provider to read config from " << m_profileToUse); -} - -ProcessCredentialsProvider::ProcessCredentialsProvider(const Aws::String& profile) : +{ + AWS_LOGSTREAM_INFO(PROCESS_LOG_TAG, "Setting process credentials provider to read config from " << m_profileToUse); +} + +ProcessCredentialsProvider::ProcessCredentialsProvider(const Aws::String& profile) : m_profileToUse(profile) -{ - AWS_LOGSTREAM_INFO(PROCESS_LOG_TAG, "Setting process credentials provider to read config from " << m_profileToUse); -} - -AWSCredentials ProcessCredentialsProvider::GetAWSCredentials() -{ - RefreshIfExpired(); - ReaderLockGuard guard(m_reloadLock); - return m_credentials; -} - - -void ProcessCredentialsProvider::Reload() -{ +{ + AWS_LOGSTREAM_INFO(PROCESS_LOG_TAG, "Setting process credentials provider to read config from " << m_profileToUse); +} + +AWSCredentials ProcessCredentialsProvider::GetAWSCredentials() +{ + RefreshIfExpired(); + ReaderLockGuard guard(m_reloadLock); + return m_credentials; +} + + +void ProcessCredentialsProvider::Reload() +{ auto profile = Aws::Config::GetCachedConfigProfile(m_profileToUse); const Aws::String &command = profile.GetCredentialProcess(); if (command.empty()) - { - AWS_LOGSTREAM_ERROR(PROCESS_LOG_TAG, "Failed to find credential process's profile: " << m_profileToUse); - return; - } + { + AWS_LOGSTREAM_ERROR(PROCESS_LOG_TAG, "Failed to find credential process's profile: " << m_profileToUse); + return; + } m_credentials = GetCredentialsFromProcess(command); } @@ -409,41 +409,41 @@ void ProcessCredentialsProvider::RefreshIfExpired() AWSCredentials Aws::Auth::GetCredentialsFromProcess(const Aws::String& process) { Aws::String command = process; - command.append(" 2>&1"); // redirect stderr to stdout - Aws::String result = Aws::Utils::StringUtils::Trim(Aws::OSVersionInfo::GetSysCommandOutput(command.c_str()).c_str()); - Json::JsonValue credentialsDoc(result); + command.append(" 2>&1"); // redirect stderr to stdout + Aws::String result = Aws::Utils::StringUtils::Trim(Aws::OSVersionInfo::GetSysCommandOutput(command.c_str()).c_str()); + Json::JsonValue credentialsDoc(result); if (!credentialsDoc.WasParseSuccessful()) - { + { AWS_LOGSTREAM_ERROR(PROFILE_LOG_TAG, "Failed to load credential from running: " << command << " Error: " << result); return {}; - } - - Aws::Utils::Json::JsonView credentialsView(credentialsDoc); - if (!credentialsView.KeyExists("Version") || credentialsView.GetInteger("Version") != 1) - { + } + + Aws::Utils::Json::JsonView credentialsView(credentialsDoc); + if (!credentialsView.KeyExists("Version") || credentialsView.GetInteger("Version") != 1) + { AWS_LOGSTREAM_ERROR(PROFILE_LOG_TAG, "Encountered an unsupported process credentials payload version:" << credentialsView.GetInteger("Version")); return {}; - } - + } + AWSCredentials credentials; - Aws::String accessKey, secretKey, token, expire; + Aws::String accessKey, secretKey, token, expire; if (credentialsView.KeyExists("AccessKeyId")) { credentials.SetAWSAccessKeyId(credentialsView.GetString("AccessKeyId")); } - + if (credentialsView.KeyExists("SecretAccessKey")) { credentials.SetAWSSecretKey(credentialsView.GetString("SecretAccessKey")); } - + if (credentialsView.KeyExists("SessionToken")) - { + { credentials.SetSessionToken(credentialsView.GetString("SessionToken")); - } - + } + if (credentialsView.KeyExists("Expiration")) - { + { const auto expiration = Aws::Utils::DateTime(credentialsView.GetString("Expiration"), DateFormat::ISO_8601); if (expiration.WasParseSuccessful()) { @@ -454,13 +454,13 @@ AWSCredentials Aws::Auth::GetCredentialsFromProcess(const Aws::String& process) AWS_LOGSTREAM_ERROR(PROFILE_LOG_TAG, "Failed to parse credential's expiration value as an ISO 8601 Date. Credentials will be marked expired."); credentials.SetExpiration(Aws::Utils::DateTime::Now()); } - } + } else { credentials.SetExpiration((std::chrono::time_point<std::chrono::system_clock>::max)()); } - + AWS_LOGSTREAM_DEBUG(PROFILE_LOG_TAG, "Successfully pulled credentials from process credential with AccessKey: " << accessKey << ", Expiration:" << credentialsView.GetString("Expiration")); return credentials; -} +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp index e1ff064840..4fc3af3287 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp @@ -37,9 +37,9 @@ #include <aws/core/Version.h> #include <aws/core/platform/OSVersionInfo.h> -#include <cstring> -#include <cassert> - +#include <cstring> +#include <cassert> + using namespace Aws; using namespace Aws::Client; using namespace Aws::Http; @@ -560,38 +560,38 @@ StreamOutcome AWSClient::MakeRequestWithUnparsedResponse(const Aws::Http::URI& u return StreamOutcome(std::move(httpResponseOutcome)); } -XmlOutcome AWSXMLClient::MakeRequestWithEventStream(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method, +XmlOutcome AWSXMLClient::MakeRequestWithEventStream(const Aws::Http::URI& uri, + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method, const char* signerName, const char* signerRegionOverride, const char* signerServiceNameOverride) const -{ +{ HttpResponseOutcome httpOutcome = AttemptExhaustively(uri, request, method, signerName, signerRegionOverride, signerServiceNameOverride); - if (httpOutcome.IsSuccess()) - { - return XmlOutcome(AmazonWebServiceResult<XmlDocument>(XmlDocument(), httpOutcome.GetResult()->GetHeaders())); - } - + if (httpOutcome.IsSuccess()) + { + return XmlOutcome(AmazonWebServiceResult<XmlDocument>(XmlDocument(), httpOutcome.GetResult()->GetHeaders())); + } + return XmlOutcome(std::move(httpOutcome)); -} - +} + XmlOutcome AWSXMLClient::MakeRequestWithEventStream(const Aws::Http::URI& uri, Http::HttpMethod method, const char* signerName, const char* requestName, const char* signerRegionOverride, const char* signerServiceNameOverride) const -{ +{ HttpResponseOutcome httpOutcome = AttemptExhaustively(uri, method, signerName, requestName, signerRegionOverride, signerServiceNameOverride); - if (httpOutcome.IsSuccess()) - { - return XmlOutcome(AmazonWebServiceResult<XmlDocument>(XmlDocument(), httpOutcome.GetResult()->GetHeaders())); - } - + if (httpOutcome.IsSuccess()) + { + return XmlOutcome(AmazonWebServiceResult<XmlDocument>(XmlDocument(), httpOutcome.GetResult()->GetHeaders())); + } + return XmlOutcome(std::move(httpOutcome)); -} - +} + void AWSClient::AddHeadersToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const Http::HeaderValueCollection& headerValues) const { @@ -666,37 +666,37 @@ void AWSClient::AddContentBodyToRequest(const std::shared_ptr<Aws::Http::HttpReq } } -Aws::String Aws::Client::GetAuthorizationHeader(const Aws::Http::HttpRequest& httpRequest) -{ - // Extract the hex-encoded signature from the authorization header rather than recalculating it. - assert(httpRequest.HasAwsAuthorization()); - const auto& authHeader = httpRequest.GetAwsAuthorization(); - auto signaturePosition = authHeader.rfind(Aws::Auth::SIGNATURE); - // The auth header should end with 'Signature=<64 chars>' - // Make sure we found the word 'Signature' in the header and make sure it's the last item followed by its 64 hex chars - if (signaturePosition == Aws::String::npos || (signaturePosition + strlen(Aws::Auth::SIGNATURE) + 1/*'=' character*/ + 64/*hex chars*/) != authHeader.length()) - { - AWS_LOGSTREAM_ERROR(AWS_CLIENT_LOG_TAG, "Failed to extract signature from authorization header."); - return {}; - } - return authHeader.substr(signaturePosition + strlen(Aws::Auth::SIGNATURE) + 1); -} - +Aws::String Aws::Client::GetAuthorizationHeader(const Aws::Http::HttpRequest& httpRequest) +{ + // Extract the hex-encoded signature from the authorization header rather than recalculating it. + assert(httpRequest.HasAwsAuthorization()); + const auto& authHeader = httpRequest.GetAwsAuthorization(); + auto signaturePosition = authHeader.rfind(Aws::Auth::SIGNATURE); + // The auth header should end with 'Signature=<64 chars>' + // Make sure we found the word 'Signature' in the header and make sure it's the last item followed by its 64 hex chars + if (signaturePosition == Aws::String::npos || (signaturePosition + strlen(Aws::Auth::SIGNATURE) + 1/*'=' character*/ + 64/*hex chars*/) != authHeader.length()) + { + AWS_LOGSTREAM_ERROR(AWS_CLIENT_LOG_TAG, "Failed to extract signature from authorization header."); + return {}; + } + return authHeader.substr(signaturePosition + strlen(Aws::Auth::SIGNATURE) + 1); +} + void AWSClient::BuildHttpRequest(const Aws::AmazonWebServiceRequest& request, const std::shared_ptr<HttpRequest>& httpRequest) const -{ +{ //do headers first since the request likely will set content-length as it's own header. - AddHeadersToRequest(httpRequest, request.GetHeaders()); - + AddHeadersToRequest(httpRequest, request.GetHeaders()); + if (request.IsEventStreamRequest()) - { + { httpRequest->AddContentBody(request.GetBody()); - } + } else { AddContentBodyToRequest(httpRequest, request.GetBody(), request.ShouldComputeContentMd5(), request.IsStreaming() && request.IsChunked() && m_httpClient->SupportsChunkedTransferEncoding()); } - + // Pass along handlers for processing data sent/received in bytes httpRequest->SetDataReceivedEventHandler(request.GetDataReceivedEventHandler()); httpRequest->SetDataSentEventHandler(request.GetDataSentEventHandler()); @@ -719,7 +719,7 @@ Aws::String AWSClient::GeneratePresignedUrl(URI& uri, HttpMethod method, long lo return request->GetURIString(); } - return {}; + return {}; } Aws::String AWSClient::GeneratePresignedUrl(URI& uri, HttpMethod method, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds) @@ -735,7 +735,7 @@ Aws::String AWSClient::GeneratePresignedUrl(URI& uri, HttpMethod method, const A return request->GetURIString(); } - return {}; + return {}; } Aws::String AWSClient::GeneratePresignedUrl(URI& uri, HttpMethod method, const char* region, long long expirationInSeconds) const @@ -775,7 +775,7 @@ Aws::String AWSClient::GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::Http return request->GetURIString(); } - return {}; + return {}; } Aws::String AWSClient::GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds) @@ -791,7 +791,7 @@ Aws::String AWSClient::GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::Http return request->GetURIString(); } - return {}; + return {}; } Aws::String AWSClient::GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, @@ -805,7 +805,7 @@ Aws::String AWSClient::GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& return httpRequest->GetURIString(); } - return {}; + return {}; } Aws::String AWSClient::GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, @@ -819,7 +819,7 @@ const Aws::Http::QueryStringParameterCollection& extraParams, long long expirati return httpRequest->GetURIString(); } - return {}; + return {}; } Aws::String AWSClient::GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, @@ -833,7 +833,7 @@ Aws::String AWSClient::GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& return httpRequest->GetURIString(); } - return {}; + return {}; } std::shared_ptr<Aws::Http::HttpRequest> AWSClient::ConvertToRequestForPresigning(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, @@ -850,12 +850,12 @@ std::shared_ptr<Aws::Http::HttpRequest> AWSClient::ConvertToRequestForPresigning return httpRequest; } -std::shared_ptr<Aws::Http::HttpResponse> AWSClient::MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const -{ - return m_httpClient->MakeRequest(request, m_readRateLimiter.get(), m_writeRateLimiter.get()); -} - +std::shared_ptr<Aws::Http::HttpResponse> AWSClient::MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const +{ + return m_httpClient->MakeRequest(request, m_readRateLimiter.get(), m_writeRateLimiter.get()); +} + //////////////////////////////////////////////////////////////////////////// AWSJsonClient::AWSJsonClient(const Aws::Client::ClientConfiguration& configuration, const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer, @@ -925,39 +925,39 @@ JsonOutcome AWSJsonClient::MakeRequest(const Aws::Http::URI& uri, return JsonOutcome(AmazonWebServiceResult<JsonValue>(JsonValue(), httpOutcome.GetResult()->GetHeaders())); } -JsonOutcome AWSJsonClient::MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const -{ - // request is assumed to be signed - std::shared_ptr<HttpResponse> httpResponse = MakeHttpRequest(request); - - if (DoesResponseGenerateError(httpResponse)) - { - AWS_LOGSTREAM_DEBUG(AWS_CLIENT_LOG_TAG, "Request returned error. Attempting to generate appropriate error codes from response"); +JsonOutcome AWSJsonClient::MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const +{ + // request is assumed to be signed + std::shared_ptr<HttpResponse> httpResponse = MakeHttpRequest(request); + + if (DoesResponseGenerateError(httpResponse)) + { + AWS_LOGSTREAM_DEBUG(AWS_CLIENT_LOG_TAG, "Request returned error. Attempting to generate appropriate error codes from response"); auto error = BuildAWSError(httpResponse); return JsonOutcome(std::move(error)); - } - - AWS_LOGSTREAM_DEBUG(AWS_CLIENT_LOG_TAG, "Request returned successful response."); - + } + + AWS_LOGSTREAM_DEBUG(AWS_CLIENT_LOG_TAG, "Request returned successful response."); + HttpResponseOutcome httpOutcome(std::move(httpResponse)); - - if (httpOutcome.GetResult()->GetResponseBody().tellp() > 0) - { - JsonValue jsonValue(httpOutcome.GetResult()->GetResponseBody()); - if (!jsonValue.WasParseSuccessful()) - { - return JsonOutcome(AWSError<CoreErrors>(CoreErrors::UNKNOWN, "Json Parser Error", jsonValue.GetErrorMessage(), false)); - } - - //this is stupid, but gcc doesn't pick up the covariant on the dereference so we have to give it a little hint. - return JsonOutcome(AmazonWebServiceResult<JsonValue>(std::move(jsonValue), - httpOutcome.GetResult()->GetHeaders(), - httpOutcome.GetResult()->GetResponseCode())); - } - - return JsonOutcome(AmazonWebServiceResult<JsonValue>(JsonValue(), httpOutcome.GetResult()->GetHeaders())); -} - + + if (httpOutcome.GetResult()->GetResponseBody().tellp() > 0) + { + JsonValue jsonValue(httpOutcome.GetResult()->GetResponseBody()); + if (!jsonValue.WasParseSuccessful()) + { + return JsonOutcome(AWSError<CoreErrors>(CoreErrors::UNKNOWN, "Json Parser Error", jsonValue.GetErrorMessage(), false)); + } + + //this is stupid, but gcc doesn't pick up the covariant on the dereference so we have to give it a little hint. + return JsonOutcome(AmazonWebServiceResult<JsonValue>(std::move(jsonValue), + httpOutcome.GetResult()->GetHeaders(), + httpOutcome.GetResult()->GetResponseCode())); + } + + return JsonOutcome(AmazonWebServiceResult<JsonValue>(JsonValue(), httpOutcome.GetResult()->GetHeaders())); +} + AWSError<CoreErrors> AWSJsonClient::BuildAWSError( const std::shared_ptr<Aws::Http::HttpResponse>& httpResponse) const { diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp index f5fa676f98..fc5e6c5dd9 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSErrorMarshaller.cpp @@ -72,7 +72,7 @@ AWSError<CoreErrors> XmlErrorMarshaller::Marshall(const Aws::Http::HttpResponse& AWS_LOGSTREAM_TRACE(AWS_ERROR_MARSHALLER_LOG_TAG, "Error response is " << doc.ConvertToString()); bool errorParsed = false; AWSError<CoreErrors> error; - if (doc.WasParseSuccessful() && !doc.GetRootElement().IsNull()) + if (doc.WasParseSuccessful() && !doc.GetRootElement().IsNull()) { XmlNode errorNode = doc.GetRootElement(); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp index e517379a77..6fcb1fd497 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp @@ -27,7 +27,7 @@ namespace Client static const char* CLIENT_CONFIG_TAG = "ClientConfiguration"; -AWS_CORE_API Aws::String ComputeUserAgentString() +AWS_CORE_API Aws::String ComputeUserAgentString() { Aws::StringStream ss; ss << "aws-sdk-cpp/" << Version::GetVersionString() << " " << Aws::OSVersionInfo::ComputeOSVersionString() @@ -54,8 +54,8 @@ ClientConfiguration::ClientConfiguration() : httpLibOverride(Aws::Http::TransferLibType::DEFAULT_CLIENT), followRedirects(FollowRedirectsPolicy::DEFAULT), disableExpectHeader(false), - enableClockSkewAdjustment(true), - enableHostPrefixInjection(true), + enableClockSkewAdjustment(true), + enableHostPrefixInjection(true), enableEndpointDiscovery(false), profileName(Aws::Auth::GetConfigProfileName()) { diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/CoreErrors.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/CoreErrors.cpp index 8c2c288dcd..1d445cc2c9 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/CoreErrors.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/client/CoreErrors.cpp @@ -5,107 +5,107 @@ #include <aws/core/client/AWSError.h> #include <aws/core/client/CoreErrors.h> -#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/utils/memory/stl/AWSMap.h> #include <aws/core/utils/HashingUtils.h> using namespace Aws::Client; using namespace Aws::Utils; using namespace Aws::Http; -#ifdef _MSC_VER -#pragma warning(push) -// VS2015 compiler's bug, warning s_CoreErrorsMapper: symbol will be dynamically initialized (implementation limitation) -#pragma warning(disable : 4592) -#endif +#ifdef _MSC_VER +#pragma warning(push) +// VS2015 compiler's bug, warning s_CoreErrorsMapper: symbol will be dynamically initialized (implementation limitation) +#pragma warning(disable : 4592) +#endif -static Aws::UniquePtr<Aws::Map<Aws::String, AWSError<CoreErrors> > > s_CoreErrorsMapper(nullptr); - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -void CoreErrorsMapper::InitCoreErrorsMapper() +static Aws::UniquePtr<Aws::Map<Aws::String, AWSError<CoreErrors> > > s_CoreErrorsMapper(nullptr); + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +void CoreErrorsMapper::InitCoreErrorsMapper() { - if (s_CoreErrorsMapper) - { - return; - } - s_CoreErrorsMapper = Aws::MakeUnique<Aws::Map<Aws::String, AWSError<CoreErrors> > >("InitCoreErrorsMapper"); + if (s_CoreErrorsMapper) + { + return; + } + s_CoreErrorsMapper = Aws::MakeUnique<Aws::Map<Aws::String, AWSError<CoreErrors> > >("InitCoreErrorsMapper"); - s_CoreErrorsMapper->emplace("IncompleteSignature", AWSError<CoreErrors>(CoreErrors::INCOMPLETE_SIGNATURE, false)); - s_CoreErrorsMapper->emplace("IncompleteSignatureException", AWSError<CoreErrors>(CoreErrors::INCOMPLETE_SIGNATURE, false)); - s_CoreErrorsMapper->emplace("InvalidSignatureException", AWSError<CoreErrors>(CoreErrors::INVALID_SIGNATURE, false)); - s_CoreErrorsMapper->emplace("InvalidSignature", AWSError<CoreErrors>(CoreErrors::INVALID_SIGNATURE, false)); - s_CoreErrorsMapper->emplace("InternalFailureException", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); - s_CoreErrorsMapper->emplace("InternalFailure", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); - s_CoreErrorsMapper->emplace("InternalServerError", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); - s_CoreErrorsMapper->emplace("InternalError", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); - s_CoreErrorsMapper->emplace("InvalidActionException", AWSError<CoreErrors>(CoreErrors::INVALID_ACTION, false)); - s_CoreErrorsMapper->emplace("InvalidAction", AWSError<CoreErrors>(CoreErrors::INVALID_ACTION, false)); - s_CoreErrorsMapper->emplace("InvalidClientTokenIdException", AWSError<CoreErrors>(CoreErrors::INVALID_CLIENT_TOKEN_ID, false)); - s_CoreErrorsMapper->emplace("InvalidClientTokenId", AWSError<CoreErrors>(CoreErrors::INVALID_CLIENT_TOKEN_ID, false)); - s_CoreErrorsMapper->emplace("InvalidParameterCombinationException", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_COMBINATION, false)); - s_CoreErrorsMapper->emplace("InvalidParameterCombination", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_COMBINATION, false)); - s_CoreErrorsMapper->emplace("InvalidParameterValueException", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_VALUE, false)); - s_CoreErrorsMapper->emplace("InvalidParameterValue", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_VALUE, false)); - s_CoreErrorsMapper->emplace("InvalidQueryParameterException", AWSError<CoreErrors>(CoreErrors::INVALID_QUERY_PARAMETER, false)); - s_CoreErrorsMapper->emplace("InvalidQueryParameter", AWSError<CoreErrors>(CoreErrors::INVALID_QUERY_PARAMETER, false)); - s_CoreErrorsMapper->emplace("MalformedQueryStringException", AWSError<CoreErrors>(CoreErrors::MALFORMED_QUERY_STRING, false)); - s_CoreErrorsMapper->emplace("MalformedQueryString", AWSError<CoreErrors>(CoreErrors::MALFORMED_QUERY_STRING, false)); - s_CoreErrorsMapper->emplace("MissingActionException", AWSError<CoreErrors>(CoreErrors::MISSING_ACTION, false)); - s_CoreErrorsMapper->emplace("MissingAction", AWSError<CoreErrors>(CoreErrors::MISSING_ACTION, false)); - s_CoreErrorsMapper->emplace("MissingAuthenticationTokenException", AWSError<CoreErrors>(CoreErrors::MISSING_AUTHENTICATION_TOKEN, false)); - s_CoreErrorsMapper->emplace("MissingAuthenticationToken", AWSError<CoreErrors>(CoreErrors::MISSING_AUTHENTICATION_TOKEN, false)); - s_CoreErrorsMapper->emplace("MissingParameterException", AWSError<CoreErrors>(CoreErrors::MISSING_PARAMETER, false)); - s_CoreErrorsMapper->emplace("MissingParameter", AWSError<CoreErrors>(CoreErrors::MISSING_PARAMETER, false)); - s_CoreErrorsMapper->emplace("OptInRequired", AWSError<CoreErrors>(CoreErrors::OPT_IN_REQUIRED, false)); - s_CoreErrorsMapper->emplace("RequestExpiredException", AWSError<CoreErrors>(CoreErrors::REQUEST_EXPIRED, true)); - s_CoreErrorsMapper->emplace("RequestExpired", AWSError<CoreErrors>(CoreErrors::REQUEST_EXPIRED, true)); - s_CoreErrorsMapper->emplace("ServiceUnavailableException", AWSError<CoreErrors>(CoreErrors::SERVICE_UNAVAILABLE, true)); - s_CoreErrorsMapper->emplace("ServiceUnavailableError", AWSError<CoreErrors>(CoreErrors::SERVICE_UNAVAILABLE, true)); - s_CoreErrorsMapper->emplace("ServiceUnavailable", AWSError<CoreErrors>(CoreErrors::SERVICE_UNAVAILABLE, true)); - s_CoreErrorsMapper->emplace("RequestThrottledException", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); - s_CoreErrorsMapper->emplace("RequestThrottled", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); - s_CoreErrorsMapper->emplace("ThrottlingException", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); - s_CoreErrorsMapper->emplace("ThrottledException", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); - s_CoreErrorsMapper->emplace("Throttling", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); - s_CoreErrorsMapper->emplace("ValidationErrorException", AWSError<CoreErrors>(CoreErrors::VALIDATION, false)); - s_CoreErrorsMapper->emplace("ValidationException", AWSError<CoreErrors>(CoreErrors::VALIDATION, false)); - s_CoreErrorsMapper->emplace("ValidationError", AWSError<CoreErrors>(CoreErrors::VALIDATION, false)); - s_CoreErrorsMapper->emplace("AccessDeniedException", AWSError<CoreErrors>(CoreErrors::ACCESS_DENIED, false)); - s_CoreErrorsMapper->emplace("AccessDenied", AWSError<CoreErrors>(CoreErrors::ACCESS_DENIED, false)); - s_CoreErrorsMapper->emplace("ResourceNotFoundException", AWSError<CoreErrors>(CoreErrors::RESOURCE_NOT_FOUND, false)); - s_CoreErrorsMapper->emplace("ResourceNotFound", AWSError<CoreErrors>(CoreErrors::RESOURCE_NOT_FOUND, false)); - s_CoreErrorsMapper->emplace("UnrecognizedClientException", AWSError<CoreErrors>(CoreErrors::UNRECOGNIZED_CLIENT, false)); - s_CoreErrorsMapper->emplace("UnrecognizedClient", AWSError<CoreErrors>(CoreErrors::UNRECOGNIZED_CLIENT, false)); - s_CoreErrorsMapper->emplace("SlowDownException", AWSError<CoreErrors>(CoreErrors::SLOW_DOWN, true)); - s_CoreErrorsMapper->emplace("SlowDown", AWSError<CoreErrors>(CoreErrors::SLOW_DOWN, true)); - s_CoreErrorsMapper->emplace("SignatureDoesNotMatchException", AWSError<CoreErrors>(CoreErrors::SIGNATURE_DOES_NOT_MATCH, false)); - s_CoreErrorsMapper->emplace("SignatureDoesNotMatch", AWSError<CoreErrors>(CoreErrors::SIGNATURE_DOES_NOT_MATCH, false)); - s_CoreErrorsMapper->emplace("InvalidAccessKeyIdException", AWSError<CoreErrors>(CoreErrors::INVALID_ACCESS_KEY_ID, false)); - s_CoreErrorsMapper->emplace("InvalidAccessKeyId", AWSError<CoreErrors>(CoreErrors::INVALID_ACCESS_KEY_ID, false)); - s_CoreErrorsMapper->emplace("RequestTimeTooSkewedException", AWSError<CoreErrors>(CoreErrors::REQUEST_TIME_TOO_SKEWED, true)); - s_CoreErrorsMapper->emplace("RequestTimeTooSkewed", AWSError<CoreErrors>(CoreErrors::REQUEST_TIME_TOO_SKEWED, true)); - s_CoreErrorsMapper->emplace("RequestTimeoutException", AWSError<CoreErrors>(CoreErrors::REQUEST_TIMEOUT, true)); - s_CoreErrorsMapper->emplace("RequestTimeout", AWSError<CoreErrors>(CoreErrors::REQUEST_TIMEOUT, true)); -} + s_CoreErrorsMapper->emplace("IncompleteSignature", AWSError<CoreErrors>(CoreErrors::INCOMPLETE_SIGNATURE, false)); + s_CoreErrorsMapper->emplace("IncompleteSignatureException", AWSError<CoreErrors>(CoreErrors::INCOMPLETE_SIGNATURE, false)); + s_CoreErrorsMapper->emplace("InvalidSignatureException", AWSError<CoreErrors>(CoreErrors::INVALID_SIGNATURE, false)); + s_CoreErrorsMapper->emplace("InvalidSignature", AWSError<CoreErrors>(CoreErrors::INVALID_SIGNATURE, false)); + s_CoreErrorsMapper->emplace("InternalFailureException", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); + s_CoreErrorsMapper->emplace("InternalFailure", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); + s_CoreErrorsMapper->emplace("InternalServerError", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); + s_CoreErrorsMapper->emplace("InternalError", AWSError<CoreErrors>(CoreErrors::INTERNAL_FAILURE, true)); + s_CoreErrorsMapper->emplace("InvalidActionException", AWSError<CoreErrors>(CoreErrors::INVALID_ACTION, false)); + s_CoreErrorsMapper->emplace("InvalidAction", AWSError<CoreErrors>(CoreErrors::INVALID_ACTION, false)); + s_CoreErrorsMapper->emplace("InvalidClientTokenIdException", AWSError<CoreErrors>(CoreErrors::INVALID_CLIENT_TOKEN_ID, false)); + s_CoreErrorsMapper->emplace("InvalidClientTokenId", AWSError<CoreErrors>(CoreErrors::INVALID_CLIENT_TOKEN_ID, false)); + s_CoreErrorsMapper->emplace("InvalidParameterCombinationException", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_COMBINATION, false)); + s_CoreErrorsMapper->emplace("InvalidParameterCombination", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_COMBINATION, false)); + s_CoreErrorsMapper->emplace("InvalidParameterValueException", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_VALUE, false)); + s_CoreErrorsMapper->emplace("InvalidParameterValue", AWSError<CoreErrors>(CoreErrors::INVALID_PARAMETER_VALUE, false)); + s_CoreErrorsMapper->emplace("InvalidQueryParameterException", AWSError<CoreErrors>(CoreErrors::INVALID_QUERY_PARAMETER, false)); + s_CoreErrorsMapper->emplace("InvalidQueryParameter", AWSError<CoreErrors>(CoreErrors::INVALID_QUERY_PARAMETER, false)); + s_CoreErrorsMapper->emplace("MalformedQueryStringException", AWSError<CoreErrors>(CoreErrors::MALFORMED_QUERY_STRING, false)); + s_CoreErrorsMapper->emplace("MalformedQueryString", AWSError<CoreErrors>(CoreErrors::MALFORMED_QUERY_STRING, false)); + s_CoreErrorsMapper->emplace("MissingActionException", AWSError<CoreErrors>(CoreErrors::MISSING_ACTION, false)); + s_CoreErrorsMapper->emplace("MissingAction", AWSError<CoreErrors>(CoreErrors::MISSING_ACTION, false)); + s_CoreErrorsMapper->emplace("MissingAuthenticationTokenException", AWSError<CoreErrors>(CoreErrors::MISSING_AUTHENTICATION_TOKEN, false)); + s_CoreErrorsMapper->emplace("MissingAuthenticationToken", AWSError<CoreErrors>(CoreErrors::MISSING_AUTHENTICATION_TOKEN, false)); + s_CoreErrorsMapper->emplace("MissingParameterException", AWSError<CoreErrors>(CoreErrors::MISSING_PARAMETER, false)); + s_CoreErrorsMapper->emplace("MissingParameter", AWSError<CoreErrors>(CoreErrors::MISSING_PARAMETER, false)); + s_CoreErrorsMapper->emplace("OptInRequired", AWSError<CoreErrors>(CoreErrors::OPT_IN_REQUIRED, false)); + s_CoreErrorsMapper->emplace("RequestExpiredException", AWSError<CoreErrors>(CoreErrors::REQUEST_EXPIRED, true)); + s_CoreErrorsMapper->emplace("RequestExpired", AWSError<CoreErrors>(CoreErrors::REQUEST_EXPIRED, true)); + s_CoreErrorsMapper->emplace("ServiceUnavailableException", AWSError<CoreErrors>(CoreErrors::SERVICE_UNAVAILABLE, true)); + s_CoreErrorsMapper->emplace("ServiceUnavailableError", AWSError<CoreErrors>(CoreErrors::SERVICE_UNAVAILABLE, true)); + s_CoreErrorsMapper->emplace("ServiceUnavailable", AWSError<CoreErrors>(CoreErrors::SERVICE_UNAVAILABLE, true)); + s_CoreErrorsMapper->emplace("RequestThrottledException", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); + s_CoreErrorsMapper->emplace("RequestThrottled", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); + s_CoreErrorsMapper->emplace("ThrottlingException", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); + s_CoreErrorsMapper->emplace("ThrottledException", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); + s_CoreErrorsMapper->emplace("Throttling", AWSError<CoreErrors>(CoreErrors::THROTTLING, true)); + s_CoreErrorsMapper->emplace("ValidationErrorException", AWSError<CoreErrors>(CoreErrors::VALIDATION, false)); + s_CoreErrorsMapper->emplace("ValidationException", AWSError<CoreErrors>(CoreErrors::VALIDATION, false)); + s_CoreErrorsMapper->emplace("ValidationError", AWSError<CoreErrors>(CoreErrors::VALIDATION, false)); + s_CoreErrorsMapper->emplace("AccessDeniedException", AWSError<CoreErrors>(CoreErrors::ACCESS_DENIED, false)); + s_CoreErrorsMapper->emplace("AccessDenied", AWSError<CoreErrors>(CoreErrors::ACCESS_DENIED, false)); + s_CoreErrorsMapper->emplace("ResourceNotFoundException", AWSError<CoreErrors>(CoreErrors::RESOURCE_NOT_FOUND, false)); + s_CoreErrorsMapper->emplace("ResourceNotFound", AWSError<CoreErrors>(CoreErrors::RESOURCE_NOT_FOUND, false)); + s_CoreErrorsMapper->emplace("UnrecognizedClientException", AWSError<CoreErrors>(CoreErrors::UNRECOGNIZED_CLIENT, false)); + s_CoreErrorsMapper->emplace("UnrecognizedClient", AWSError<CoreErrors>(CoreErrors::UNRECOGNIZED_CLIENT, false)); + s_CoreErrorsMapper->emplace("SlowDownException", AWSError<CoreErrors>(CoreErrors::SLOW_DOWN, true)); + s_CoreErrorsMapper->emplace("SlowDown", AWSError<CoreErrors>(CoreErrors::SLOW_DOWN, true)); + s_CoreErrorsMapper->emplace("SignatureDoesNotMatchException", AWSError<CoreErrors>(CoreErrors::SIGNATURE_DOES_NOT_MATCH, false)); + s_CoreErrorsMapper->emplace("SignatureDoesNotMatch", AWSError<CoreErrors>(CoreErrors::SIGNATURE_DOES_NOT_MATCH, false)); + s_CoreErrorsMapper->emplace("InvalidAccessKeyIdException", AWSError<CoreErrors>(CoreErrors::INVALID_ACCESS_KEY_ID, false)); + s_CoreErrorsMapper->emplace("InvalidAccessKeyId", AWSError<CoreErrors>(CoreErrors::INVALID_ACCESS_KEY_ID, false)); + s_CoreErrorsMapper->emplace("RequestTimeTooSkewedException", AWSError<CoreErrors>(CoreErrors::REQUEST_TIME_TOO_SKEWED, true)); + s_CoreErrorsMapper->emplace("RequestTimeTooSkewed", AWSError<CoreErrors>(CoreErrors::REQUEST_TIME_TOO_SKEWED, true)); + s_CoreErrorsMapper->emplace("RequestTimeoutException", AWSError<CoreErrors>(CoreErrors::REQUEST_TIMEOUT, true)); + s_CoreErrorsMapper->emplace("RequestTimeout", AWSError<CoreErrors>(CoreErrors::REQUEST_TIMEOUT, true)); +} -void CoreErrorsMapper::CleanupCoreErrorsMapper() -{ - if (s_CoreErrorsMapper) - { - s_CoreErrorsMapper = nullptr; - } -} +void CoreErrorsMapper::CleanupCoreErrorsMapper() +{ + if (s_CoreErrorsMapper) + { + s_CoreErrorsMapper = nullptr; + } +} -AWSError<CoreErrors> CoreErrorsMapper::GetErrorForName(const char* errorName) -{ - auto iter = s_CoreErrorsMapper->find(errorName); - if (iter != s_CoreErrorsMapper->end()) - { - return iter->second; - } - return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false); +AWSError<CoreErrors> CoreErrorsMapper::GetErrorForName(const char* errorName) +{ + auto iter = s_CoreErrorsMapper->find(errorName); + if (iter != s_CoreErrorsMapper->end()) + { + return iter->second; + } + return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false); } AWS_CORE_API AWSError<CoreErrors> CoreErrorsMapper::GetErrorForHttpResponseCode(HttpResponseCode code) diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp index 9ec2e54f55..3cb761129a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp @@ -139,7 +139,7 @@ namespace Aws } } - FlushProfileAndReset(line, std::string::npos, std::string::npos); + FlushProfileAndReset(line, std::string::npos, std::string::npos); } private: @@ -204,13 +204,13 @@ namespace Aws AWS_LOGSTREAM_DEBUG(PARSER_TAG, "found source profile " << sourceProfileIter->second); profile.SetSourceProfile(sourceProfileIter->second); } - - auto credentialProcessIter = m_profileKeyValuePairs.find(CREDENTIAL_PROCESS_COMMAND); - if (credentialProcessIter != m_profileKeyValuePairs.end()) - { - AWS_LOGSTREAM_DEBUG(PARSER_TAG, "found credential process " << credentialProcessIter->second); - profile.SetCredentialProcess(credentialProcessIter->second); - } + + auto credentialProcessIter = m_profileKeyValuePairs.find(CREDENTIAL_PROCESS_COMMAND); + if (credentialProcessIter != m_profileKeyValuePairs.end()) + { + AWS_LOGSTREAM_DEBUG(PARSER_TAG, "found credential process " << credentialProcessIter->second); + profile.SetCredentialProcess(credentialProcessIter->second); + } profile.SetAllKeyValPairs(m_profileKeyValuePairs); m_foundProfiles[profile.GetName()] = std::move(profile); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp index a556e39a5d..41902693b8 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/HttpClientFactory.cpp @@ -100,7 +100,7 @@ namespace Aws // to error by -Werror) about the unused clientConfiguration parameter. We // prevent that warning with AWS_UNREFERENCED_PARAM. AWS_UNREFERENCED_PARAM(clientConfiguration); - AWS_LOGSTREAM_WARN(HTTP_CLIENT_FACTORY_ALLOCATION_TAG, "SDK was built without an Http implementation, default http client factory can't create an Http client instance."); + AWS_LOGSTREAM_WARN(HTTP_CLIENT_FACTORY_ALLOCATION_TAG, "SDK was built without an Http implementation, default http client factory can't create an Http client instance."); return nullptr; #endif } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/URI.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/URI.cpp index a2239df54b..399665ae0c 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/URI.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/URI.cpp @@ -117,8 +117,8 @@ Aws::String URI::URLEncodePathRFC3986(const Aws::String& path) ss << '/'; for(unsigned char c : segment) // alnum results in UB if the value of c is not unsigned char & is not EOF { - // §2.3 unreserved characters - if (StringUtils::IsAlnum(c)) + // §2.3 unreserved characters + if (StringUtils::IsAlnum(c)) { ss << c; continue; @@ -136,7 +136,7 @@ Aws::String URI::URLEncodePathRFC3986(const Aws::String& path) ss << c; break; default: - ss << '%' << std::setfill('0') << std::setw(2) << (int)((unsigned char)c) << std::setw(0); + ss << '%' << std::setfill('0') << std::setw(2) << (int)((unsigned char)c) << std::setw(0); } } } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHandleContainer.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHandleContainer.cpp index 1a965cd795..ac7d39e7e9 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHandleContainer.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHandleContainer.cpp @@ -147,7 +147,7 @@ void CurlHandleContainer::SetDefaultOptionsOnHandle(CURL* handle) curl_easy_setopt(handle, CURLOPT_TCP_KEEPALIVE, m_enableTcpKeepAlive ? 1L : 0L); curl_easy_setopt(handle, CURLOPT_TCP_KEEPINTVL, m_tcpKeepAliveIntervalMs / 1000); curl_easy_setopt(handle, CURLOPT_TCP_KEEPIDLE, m_tcpKeepAliveIntervalMs / 1000); -#ifdef CURL_HAS_H2 - curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); -#endif +#ifdef CURL_HAS_H2 + curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); +#endif } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp index 2fb9cc9643..1523cbd5f9 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp @@ -572,10 +572,10 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr< curl_easy_setopt(connectionHandle, CURLOPT_FOLLOWLOCATION, 0L); } -#ifdef ENABLE_CURL_LOGGING - curl_easy_setopt(connectionHandle, CURLOPT_VERBOSE, 1); - curl_easy_setopt(connectionHandle, CURLOPT_DEBUGFUNCTION, CurlDebugCallback); -#endif +#ifdef ENABLE_CURL_LOGGING + curl_easy_setopt(connectionHandle, CURLOPT_VERBOSE, 1); + curl_easy_setopt(connectionHandle, CURLOPT_DEBUGFUNCTION, CurlDebugCallback); +#endif if (m_isUsingProxy) { Aws::StringStream ss; @@ -590,11 +590,11 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr< { curl_easy_setopt(connectionHandle, CURLOPT_PROXY_CAINFO, m_proxyCaFile.c_str()); } - if (!m_proxyUserName.empty() || !m_proxyPassword.empty()) - { - curl_easy_setopt(connectionHandle, CURLOPT_PROXYUSERNAME, m_proxyUserName.c_str()); - curl_easy_setopt(connectionHandle, CURLOPT_PROXYPASSWORD, m_proxyPassword.c_str()); - } + if (!m_proxyUserName.empty() || !m_proxyPassword.empty()) + { + curl_easy_setopt(connectionHandle, CURLOPT_PROXYUSERNAME, m_proxyUserName.c_str()); + curl_easy_setopt(connectionHandle, CURLOPT_PROXYPASSWORD, m_proxyPassword.c_str()); + } #ifdef CURL_HAS_TLS_PROXY if (!m_proxySSLCertPath.empty()) { @@ -702,12 +702,12 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr< request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::SslLatency), static_cast<int64_t>(timep * 1000)); } - const char* ip = nullptr; - auto curlGetInfoResult = curl_easy_getinfo(connectionHandle, CURLINFO_PRIMARY_IP, &ip); // Get the IP address of the remote endpoint - if (curlGetInfoResult == CURLE_OK && ip) - { + const char* ip = nullptr; + auto curlGetInfoResult = curl_easy_getinfo(connectionHandle, CURLINFO_PRIMARY_IP, &ip); // Get the IP address of the remote endpoint + if (curlGetInfoResult == CURLE_OK && ip) + { request->SetResolvedRemoteHost(ip); - } + } if (curlResponseCode != CURLE_OK) { m_curlHandleContainer.DestroyCurlHandle(connectionHandle); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp index 24145e4d92..3f713161a6 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp @@ -36,13 +36,13 @@ static const char RESOURCE_CLIENT_CONFIGURATION_ALLOCATION_TAG[] = "AWSHttpResou static const char EC2_METADATA_CLIENT_LOG_TAG[] = "EC2MetadataClient"; static const char ECS_CREDENTIALS_CLIENT_LOG_TAG[] = "ECSCredentialsClient"; -namespace Aws -{ - namespace Client - { - Aws::String ComputeUserAgentString(); - } - +namespace Aws +{ + namespace Client + { + Aws::String ComputeUserAgentString(); + } + namespace Internal { static ClientConfiguration MakeDefaultHttpResourceClientConfiguration(const char *logtag) @@ -115,7 +115,7 @@ namespace Aws Aws::Utils::Stream::DefaultResponseStreamFactoryMethod)); request->SetUserAgent(ComputeUserAgentString()); - + if (authToken) { request->SetHeaderValue(Aws::Http::AWS_AUTHORIZATION_HEADER, authToken); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/monitoring/DefaultMonitoring.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/monitoring/DefaultMonitoring.cpp index 9953004bc3..757ca38aad 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/monitoring/DefaultMonitoring.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/monitoring/DefaultMonitoring.cpp @@ -47,7 +47,7 @@ namespace Aws int retryCount = 0; bool lastAttemptSucceeded = false; bool lastErrorRetryable = false; //doesn't apply if last attempt succeeded. - const Aws::Client::HttpResponseOutcome* outcome = nullptr; + const Aws::Client::HttpResponseOutcome* outcome = nullptr; }; static inline void FillRequiredFieldsToJson(Json::JsonValue& json, @@ -56,15 +56,15 @@ namespace Aws const Aws::String& api, const Aws::String& clientId, const DateTime& timestamp, - int version, - const Aws::String& userAgent) + int version, + const Aws::String& userAgent) { json.WithString("Type", type) .WithString("Service", service) .WithString("Api", api) .WithString("ClientId", clientId.substr(0, CLIENT_ID_LENGTH_LIMIT)) .WithInt64("Timestamp", timestamp.Millis()) - .WithInteger("Version", version) + .WithInteger("Version", version) .WithString("UserAgent", userAgent.substr(0, USER_AGENT_LENGTH_LIMIT)); } @@ -106,30 +106,30 @@ namespace Aws } static inline void FillOptionalApiCallFieldsToJson(Json::JsonValue& json, - const Aws::Http::HttpRequest* request, - const Aws::Client::HttpResponseOutcome& outcome) + const Aws::Http::HttpRequest* request, + const Aws::Client::HttpResponseOutcome& outcome) { if (!request->GetSigningRegion().empty()) { json.WithString("Region", request->GetSigningRegion()); } - if (!outcome.IsSuccess()) - { + if (!outcome.IsSuccess()) + { if (outcome.GetError().GetExceptionName().empty()) // Not Aws Exception - { - json.WithString("FinalSdkExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); - } - else // Aws Exception - { - json.WithString("FinalAwsException", outcome.GetError().GetExceptionName()) - .WithString("FinalAwsExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); - } - json.WithInteger("FinalHttpStatusCode", static_cast<int>(outcome.GetError().GetResponseCode())); - } + { + json.WithString("FinalSdkExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); + } + else // Aws Exception + { + json.WithString("FinalAwsException", outcome.GetError().GetExceptionName()) + .WithString("FinalAwsExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); + } + json.WithInteger("FinalHttpStatusCode", static_cast<int>(outcome.GetError().GetResponseCode())); + } else - { - json.WithInteger("FinalHttpStatusCode", static_cast<int>(outcome.GetResult()->GetResponseCode())); - } + { + json.WithInteger("FinalHttpStatusCode", static_cast<int>(outcome.GetResult()->GetResponseCode())); + } } static inline void FillOptionalApiAttemptFieldsToJson(Json::JsonValue& json, @@ -164,19 +164,19 @@ namespace Aws { if (outcome.GetError().GetExceptionName().empty()) // Not Aws Exception { - json.WithString("SdkExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); + json.WithString("SdkExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); } else // Aws Exception { - json.WithString("AwsException", outcome.GetError().GetExceptionName()) - .WithString("AwsExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); + json.WithString("AwsException", outcome.GetError().GetExceptionName()) + .WithString("AwsExceptionMessage", outcome.GetError().GetMessage().substr(0, ERROR_MESSAGE_LENGTH_LIMIT)); } - json.WithInteger("HttpStatusCode", static_cast<int>(outcome.GetError().GetResponseCode())); + json.WithInteger("HttpStatusCode", static_cast<int>(outcome.GetError().GetResponseCode())); } else - { - json.WithInteger("HttpStatusCode", static_cast<int>(outcome.GetResult()->GetResponseCode())); - } + { + json.WithInteger("HttpStatusCode", static_cast<int>(outcome.GetResult()->GetResponseCode())); + } // Optional MetricsCollectedFromCore ExportHttpMetricsToJson(json, metricsFromCore.httpClientMetrics, HttpClientMetricsType::AcquireConnectionLatency); @@ -238,11 +238,11 @@ namespace Aws AWS_UNREFERENCED_PARAM(request); AWS_LOGSTREAM_DEBUG(DEFAULT_MONITORING_ALLOC_TAG, "OnRequestFinish Service: " << serviceName << "Request: " << requestName); - DefaultContext* defaultContext = static_cast<DefaultContext*>(context); + DefaultContext* defaultContext = static_cast<DefaultContext*>(context); Aws::Utils::Json::JsonValue json; - FillRequiredFieldsToJson(json, "ApiCall", serviceName, requestName, m_clientId, defaultContext->apiCallStartTime, DEFAULT_MONITORING_VERSION, request->GetUserAgent()); + FillRequiredFieldsToJson(json, "ApiCall", serviceName, requestName, m_clientId, defaultContext->apiCallStartTime, DEFAULT_MONITORING_VERSION, request->GetUserAgent()); FillRequiredApiCallFieldsToJson(json, defaultContext->retryCount + 1, (DateTime::Now() - defaultContext->apiCallStartTime).count(), (!defaultContext->lastAttemptSucceeded && defaultContext->lastErrorRetryable)); - FillOptionalApiCallFieldsToJson(json, request.get(), *(defaultContext->outcome)); + FillOptionalApiCallFieldsToJson(json, request.get(), *(defaultContext->outcome)); Aws::String compactData = json.View().WriteCompact(); m_udp.SendData(reinterpret_cast<const uint8_t*>(compactData.c_str()), static_cast<int>(compactData.size())); AWS_LOGSTREAM_DEBUG(DEFAULT_MONITORING_ALLOC_TAG, "Send API Metrics: \n" << json.View().WriteReadable()); @@ -253,13 +253,13 @@ namespace Aws const std::shared_ptr<const Aws::Http::HttpRequest>& request, const Aws::Client::HttpResponseOutcome& outcome, const CoreMetricsCollection& metricsFromCore, void* context) const { - DefaultContext* defaultContext = static_cast<DefaultContext*>(context); - defaultContext->outcome = &outcome; + DefaultContext* defaultContext = static_cast<DefaultContext*>(context); + defaultContext->outcome = &outcome; defaultContext->lastAttemptSucceeded = outcome.IsSuccess() ? true : false; defaultContext->lastErrorRetryable = (!outcome.IsSuccess() && outcome.GetError().ShouldRetry()) ? true : false; Aws::Utils::Json::JsonValue json; - FillRequiredFieldsToJson(json, "ApiCallAttempt", serviceName, requestName, m_clientId, defaultContext->attemptStartTime, DEFAULT_MONITORING_VERSION, request->GetUserAgent()); - FillRequiredApiAttemptFieldsToJson(json, request->GetUri().GetAuthority(), (DateTime::Now() - defaultContext->attemptStartTime).count()); + FillRequiredFieldsToJson(json, "ApiCallAttempt", serviceName, requestName, m_clientId, defaultContext->attemptStartTime, DEFAULT_MONITORING_VERSION, request->GetUserAgent()); + FillRequiredApiAttemptFieldsToJson(json, request->GetUri().GetAuthority(), (DateTime::Now() - defaultContext->attemptStartTime).count()); FillOptionalApiAttemptFieldsToJson(json, request.get(), outcome, metricsFromCore); Aws::String compactData = json.View().WriteCompact(); AWS_LOGSTREAM_DEBUG(DEFAULT_MONITORING_ALLOC_TAG, "Send Attempt Metrics: \n" << json.View().WriteReadable()); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/linux-shared/OSVersionInfo.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/linux-shared/OSVersionInfo.cpp index 040173a2e5..21597d5629 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/linux-shared/OSVersionInfo.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/linux-shared/OSVersionInfo.cpp @@ -37,7 +37,7 @@ Aws::String GetSysCommandOutput(const char* command) return Aws::Utils::StringUtils::Trim(outputStr.c_str()); } - return {}; + return {}; } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/DNS.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/DNS.cpp index ce588150e2..f0f01c0357 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/DNS.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/DNS.cpp @@ -4,7 +4,7 @@ */ #include <aws/core/utils/DNS.h> -#include <aws/core/utils/StringUtils.h> +#include <aws/core/utils/StringUtils.h> namespace Aws { @@ -24,32 +24,32 @@ namespace Aws if (label.size() > 63) return false; - if (!StringUtils::IsAlnum(label.front())) + if (!StringUtils::IsAlnum(label.front())) return false; // '-' is not acceptable as the first character - if (!StringUtils::IsAlnum(label.back())) + if (!StringUtils::IsAlnum(label.back())) return false; // '-' is not acceptable as the last character for (size_t i = 1, e = label.size() - 1; i < e; ++i) { auto c = label[i]; - if (c != '-' && !StringUtils::IsAlnum(c)) + if (c != '-' && !StringUtils::IsAlnum(c)) return false; } return true; } - - bool IsValidHost(const Aws::String& host) - { - // Valid DNS hostnames are composed of valid DNS labels separated by a period. - auto labels = StringUtils::Split(host, '.'); - if (labels.empty()) - { - return false; - } - - return !std::any_of(labels.begin(), labels.end(), [](const Aws::String& label){ return !IsValidDnsLabel(label); }); - } + + bool IsValidHost(const Aws::String& host) + { + // Valid DNS hostnames are composed of valid DNS labels separated by a period. + auto labels = StringUtils::Split(host, '.'); + if (labels.empty()) + { + return false; + } + + return !std::any_of(labels.begin(), labels.end(), [](const Aws::String& label){ return !IsValidDnsLabel(label); }); + } } } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/FileSystemUtils.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/FileSystemUtils.cpp index c47f750960..e99dae04ce 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/FileSystemUtils.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/FileSystemUtils.cpp @@ -17,7 +17,7 @@ Aws::String PathUtils::GetFileNameFromPathWithoutExt(const Aws::String& path) } if (endPos == 0) // fileName is "." { - return {}; + return {}; } return fileName.substr(0, endPos); @@ -33,7 +33,7 @@ Aws::String PathUtils::GetFileNameFromPathWithExt(const Aws::String& path) size_t startPos = path.find_last_of(Aws::FileSystem::PATH_DELIM); if (startPos == path.size() - 1) { - return {}; + return {}; } if (startPos == std::string::npos) @@ -48,4 +48,4 @@ Aws::String PathUtils::GetFileNameFromPathWithExt(const Aws::String& path) size_t endPos = path.size() - 1; return path.substr(startPos, endPos - startPos + 1); -} +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/HashingUtils.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/HashingUtils.cpp index 147bddf33e..ed4f3bf765 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/HashingUtils.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/HashingUtils.cpp @@ -5,7 +5,7 @@ #include <aws/core/utils/logging/LogMacros.h> #include <aws/core/utils/HashingUtils.h> -#include <aws/core/utils/StringUtils.h> +#include <aws/core/utils/StringUtils.h> #include <aws/core/utils/base64/Base64.h> #include <aws/core/utils/crypto/Sha256.h> #include <aws/core/utils/crypto/Sha256HMAC.h> @@ -139,16 +139,16 @@ ByteBuffer HashingUtils::CalculateSHA256TreeHash(Aws::IOStream& stream) Aws::String HashingUtils::HexEncode(const ByteBuffer& message) { - Aws::String encoded; - encoded.reserve(2 * message.GetLength()); + Aws::String encoded; + encoded.reserve(2 * message.GetLength()); for (unsigned i = 0; i < message.GetLength(); ++i) { - encoded.push_back("0123456789abcdef"[message[i] >> 4]); - encoded.push_back("0123456789abcdef"[message[i] & 0x0f]); + encoded.push_back("0123456789abcdef"[message[i] >> 4]); + encoded.push_back("0123456789abcdef"[message[i] & 0x0f]); } - return encoded; + return encoded; } ByteBuffer HashingUtils::HexDecode(const Aws::String& str) @@ -176,7 +176,7 @@ ByteBuffer HashingUtils::HexDecode(const Aws::String& str) for (size_t i = readIndex; i < str.length(); i += 2) { - if(!StringUtils::IsAlnum(str[i]) || !StringUtils::IsAlnum(str[i + 1])) + if(!StringUtils::IsAlnum(str[i]) || !StringUtils::IsAlnum(str[i + 1])) { //contains non-hex characters assert(0); @@ -226,7 +226,7 @@ int HashingUtils::HashString(const char* strToHash) if (!strToHash) return 0; - unsigned hash = 0; + unsigned hash = 0; while (char charValue = *strToHash++) { hash = charValue + 31 * hash; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/StringUtils.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/StringUtils.cpp index e1deb3f046..22e3c8e973 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/StringUtils.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/StringUtils.cpp @@ -155,8 +155,8 @@ Aws::String StringUtils::URLEncode(const char* unsafe) size_t unsafeLength = strlen(unsafe); for (auto i = unsafe, n = unsafe + unsafeLength; i != n; ++i) { - char c = *i; - if (IsAlnum(c) || c == '-' || c == '_' || c == '.' || c == '~') + char c = *i; + if (IsAlnum(c) || c == '-' || c == '_' || c == '.' || c == '~') { escaped << (char)c; } @@ -209,77 +209,77 @@ Aws::String StringUtils::URLEncode(double unsafe) Aws::String StringUtils::URLDecode(const char* safe) { - Aws::String unescaped; + Aws::String unescaped; - for (; *safe; safe++) + for (; *safe; safe++) { - switch(*safe) + switch(*safe) { - case '%': - { - int hex = 0; - auto ch = *++safe; - if (ch >= '0' && ch <= '9') - { - hex = (ch - '0') * 16; - } - else if (ch >= 'A' && ch <= 'F') - { - hex = (ch - 'A' + 10) * 16; - } - else if (ch >= 'a' && ch <= 'f') - { - hex = (ch - 'a' + 10) * 16; - } - else - { - unescaped.push_back('%'); - if (ch == 0) - { - return unescaped; - } - unescaped.push_back(ch); - break; - } - - ch = *++safe; - if (ch >= '0' && ch <= '9') - { - hex += (ch - '0'); - } - else if (ch >= 'A' && ch <= 'F') - { - hex += (ch - 'A' + 10); - } - else if (ch >= 'a' && ch <= 'f') - { - hex += (ch - 'a' + 10); - } - else - { - unescaped.push_back('%'); - unescaped.push_back(*(safe - 1)); - if (ch == 0) - { - return unescaped; - } - unescaped.push_back(ch); - break; - } - - unescaped.push_back(char(hex)); - break; - } - case '+': - unescaped.push_back(' '); - break; - default: - unescaped.push_back(*safe); - break; + case '%': + { + int hex = 0; + auto ch = *++safe; + if (ch >= '0' && ch <= '9') + { + hex = (ch - '0') * 16; + } + else if (ch >= 'A' && ch <= 'F') + { + hex = (ch - 'A' + 10) * 16; + } + else if (ch >= 'a' && ch <= 'f') + { + hex = (ch - 'a' + 10) * 16; + } + else + { + unescaped.push_back('%'); + if (ch == 0) + { + return unescaped; + } + unescaped.push_back(ch); + break; + } + + ch = *++safe; + if (ch >= '0' && ch <= '9') + { + hex += (ch - '0'); + } + else if (ch >= 'A' && ch <= 'F') + { + hex += (ch - 'A' + 10); + } + else if (ch >= 'a' && ch <= 'f') + { + hex += (ch - 'a' + 10); + } + else + { + unescaped.push_back('%'); + unescaped.push_back(*(safe - 1)); + if (ch == 0) + { + return unescaped; + } + unescaped.push_back(ch); + break; + } + + unescaped.push_back(char(hex)); + break; + } + case '+': + unescaped.push_back(' '); + break; + default: + unescaped.push_back(*safe); + break; } } - return unescaped; + return unescaped; } static bool IsSpace(int ch) diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/UUID.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/UUID.cpp index 862f3eacdd..b1915ba144 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/UUID.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/UUID.cpp @@ -14,7 +14,7 @@ namespace Aws { namespace Utils { - static const size_t UUID_STR_SIZE = 0x24u; // 36 characters + static const size_t UUID_STR_SIZE = 0x24u; // 36 characters static const size_t VERSION_LOCATION = 0x06u; static const size_t VARIANT_LOCATION = 0x08u; static const unsigned char VERSION = 0x40u; @@ -22,12 +22,12 @@ namespace Aws static const unsigned char VARIANT = 0x80u; static const unsigned char VARIANT_MASK = 0x3Fu; - static void hexify(Aws::String& ss, const unsigned char* toWrite, size_t min, size_t max) + static void hexify(Aws::String& ss, const unsigned char* toWrite, size_t min, size_t max) { for (size_t i = min; i < max; ++i) { - ss.push_back("0123456789ABCDEF"[toWrite[i] >> 4]); - ss.push_back("0123456789ABCDEF"[toWrite[i] & 0x0F]); + ss.push_back("0123456789ABCDEF"[toWrite[i] >> 4]); + ss.push_back("0123456789ABCDEF"[toWrite[i] & 0x0F]); } } @@ -50,23 +50,23 @@ namespace Aws UUID::operator Aws::String() const { - Aws::String ss; - ss.reserve(UUID_STR_SIZE); - hexify(ss, m_uuid, 0, 4); - ss.push_back('-'); + Aws::String ss; + ss.reserve(UUID_STR_SIZE); + hexify(ss, m_uuid, 0, 4); + ss.push_back('-'); - hexify(ss, m_uuid, 4, 6); - ss.push_back('-'); + hexify(ss, m_uuid, 4, 6); + ss.push_back('-'); - hexify(ss, m_uuid, 6, 8); - ss.push_back('-'); + hexify(ss, m_uuid, 6, 8); + ss.push_back('-'); - hexify(ss, m_uuid, 8, 10); - ss.push_back('-'); + hexify(ss, m_uuid, 8, 10); + ss.push_back('-'); - hexify(ss, m_uuid, 10, 16); + hexify(ss, m_uuid, 10, 16); - return ss; + return ss; } UUID UUID::RandomUUID() diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/base64/Base64.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/base64/Base64.cpp index 2103d6d5a6..9f92eae92a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/base64/Base64.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/base64/Base64.cpp @@ -122,8 +122,8 @@ Aws::Utils::ByteBuffer Base64::Decode(const Aws::String& str) const size_t Base64::CalculateBase64DecodedLength(const Aws::String& b64input) { - const size_t len = b64input.length(); - if(len < 2) + const size_t len = b64input.length(); + if(len < 2) { return 0; } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventHeader.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventHeader.cpp index c3c989bedb..6b5bf41441 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventHeader.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventHeader.cpp @@ -1,107 +1,107 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#include <aws/core/utils/event/EventHeader.h> -#include <aws/core/utils/HashingUtils.h> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - static const int HASH_BOOL_TRUE = HashingUtils::HashString("BOOL_TRUE"); - static const int HASH_BOOL_FALSE = HashingUtils::HashString("BOOL_FALSE"); - static const int HASH_BYTE = HashingUtils::HashString("BYTE"); - static const int HASH_INT16 = HashingUtils::HashString("INT16"); - static const int HASH_INT32 = HashingUtils::HashString("INT32"); - static const int HASH_INT64 = HashingUtils::HashString("INT64"); - static const int HASH_BYTE_BUF = HashingUtils::HashString("BYTE_BUFFER"); - static const int HASH_STRING = HashingUtils::HashString("STRING"); - static const int HASH_TIMESTAMP = HashingUtils::HashString("TIMESTAMP"); - static const int HASH_UUID = HashingUtils::HashString("UUID"); - - EventHeaderValue::EventHeaderType EventHeaderValue::GetEventHeaderTypeForName(const Aws::String& name) - { - int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str()); - if (hashCode == HASH_BOOL_TRUE) - { - return EventHeaderType::BOOL_TRUE; - } - else if (hashCode == HASH_BOOL_FALSE) - { - return EventHeaderType::BOOL_FALSE; - } - else if (hashCode == HASH_BYTE) - { - return EventHeaderType::BYTE; - } - else if (hashCode == HASH_INT16) - { - return EventHeaderType::INT16; - } - else if (hashCode == HASH_INT32) - { - return EventHeaderType::INT32; - } - else if (hashCode == HASH_INT64) - { - return EventHeaderType::INT64; - } - else if (hashCode == HASH_BYTE_BUF) - { - return EventHeaderType::BYTE_BUF; - } - else if (hashCode == HASH_STRING) - { - return EventHeaderType::STRING; - } - else if (hashCode == HASH_TIMESTAMP) - { - return EventHeaderType::TIMESTAMP; - } - else if (hashCode == HASH_UUID) - { - return EventHeaderType::UUID; - } - else - { - return EventHeaderType::UNKNOWN; - } - } - - Aws::String EventHeaderValue::GetNameForEventHeaderType(EventHeaderType value) - { - switch (value) - { - case EventHeaderType::BOOL_TRUE: - return "BOOL_TRUE"; - case EventHeaderType::BOOL_FALSE: - return "BOOL_FALSE"; - case EventHeaderType::BYTE: - return "BYTE"; - case EventHeaderType::INT16: - return "INT16"; - case EventHeaderType::INT32: - return "INT32"; - case EventHeaderType::INT64: - return "INT64"; - case EventHeaderType::BYTE_BUF: - return "BYTE_BUF"; - case EventHeaderType::STRING: - return "STRING"; - case EventHeaderType::TIMESTAMP: - return "TIMESTAMP"; - case EventHeaderType::UUID: - return "UUID"; - default: - return "UNKNOWN"; - } - } - - } - } -} - + */ + +#include <aws/core/utils/event/EventHeader.h> +#include <aws/core/utils/HashingUtils.h> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + static const int HASH_BOOL_TRUE = HashingUtils::HashString("BOOL_TRUE"); + static const int HASH_BOOL_FALSE = HashingUtils::HashString("BOOL_FALSE"); + static const int HASH_BYTE = HashingUtils::HashString("BYTE"); + static const int HASH_INT16 = HashingUtils::HashString("INT16"); + static const int HASH_INT32 = HashingUtils::HashString("INT32"); + static const int HASH_INT64 = HashingUtils::HashString("INT64"); + static const int HASH_BYTE_BUF = HashingUtils::HashString("BYTE_BUFFER"); + static const int HASH_STRING = HashingUtils::HashString("STRING"); + static const int HASH_TIMESTAMP = HashingUtils::HashString("TIMESTAMP"); + static const int HASH_UUID = HashingUtils::HashString("UUID"); + + EventHeaderValue::EventHeaderType EventHeaderValue::GetEventHeaderTypeForName(const Aws::String& name) + { + int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str()); + if (hashCode == HASH_BOOL_TRUE) + { + return EventHeaderType::BOOL_TRUE; + } + else if (hashCode == HASH_BOOL_FALSE) + { + return EventHeaderType::BOOL_FALSE; + } + else if (hashCode == HASH_BYTE) + { + return EventHeaderType::BYTE; + } + else if (hashCode == HASH_INT16) + { + return EventHeaderType::INT16; + } + else if (hashCode == HASH_INT32) + { + return EventHeaderType::INT32; + } + else if (hashCode == HASH_INT64) + { + return EventHeaderType::INT64; + } + else if (hashCode == HASH_BYTE_BUF) + { + return EventHeaderType::BYTE_BUF; + } + else if (hashCode == HASH_STRING) + { + return EventHeaderType::STRING; + } + else if (hashCode == HASH_TIMESTAMP) + { + return EventHeaderType::TIMESTAMP; + } + else if (hashCode == HASH_UUID) + { + return EventHeaderType::UUID; + } + else + { + return EventHeaderType::UNKNOWN; + } + } + + Aws::String EventHeaderValue::GetNameForEventHeaderType(EventHeaderType value) + { + switch (value) + { + case EventHeaderType::BOOL_TRUE: + return "BOOL_TRUE"; + case EventHeaderType::BOOL_FALSE: + return "BOOL_FALSE"; + case EventHeaderType::BYTE: + return "BYTE"; + case EventHeaderType::INT16: + return "INT16"; + case EventHeaderType::INT32: + return "INT32"; + case EventHeaderType::INT64: + return "INT64"; + case EventHeaderType::BYTE_BUF: + return "BYTE_BUF"; + case EventHeaderType::STRING: + return "STRING"; + case EventHeaderType::TIMESTAMP: + return "TIMESTAMP"; + case EventHeaderType::UUID: + return "UUID"; + default: + return "UNKNOWN"; + } + } + + } + } +} + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventMessage.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventMessage.cpp index de8b904775..811d116223 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventMessage.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventMessage.cpp @@ -1,70 +1,70 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#include <aws/core/utils/event/EventMessage.h> -#include <aws/core/utils/HashingUtils.h> -#include <algorithm> -#include <iterator> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - const char EVENT_TYPE_HEADER[] = ":event-type"; - const char CONTENT_TYPE_HEADER[] = ":content-type"; - const char MESSAGE_TYPE_HEADER[] = ":message-type"; - const char ERROR_CODE_HEADER[] = ":error-code"; - const char ERROR_MESSAGE_HEADER[] = ":error-message"; + */ + +#include <aws/core/utils/event/EventMessage.h> +#include <aws/core/utils/HashingUtils.h> +#include <algorithm> +#include <iterator> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + const char EVENT_TYPE_HEADER[] = ":event-type"; + const char CONTENT_TYPE_HEADER[] = ":content-type"; + const char MESSAGE_TYPE_HEADER[] = ":message-type"; + const char ERROR_CODE_HEADER[] = ":error-code"; + const char ERROR_MESSAGE_HEADER[] = ":error-message"; const char EXCEPTION_TYPE_HEADER[] = ":exception-type"; - - static const int EVENT_HASH = HashingUtils::HashString("event"); - static const int ERROR_HASH = HashingUtils::HashString("error"); + + static const int EVENT_HASH = HashingUtils::HashString("event"); + static const int ERROR_HASH = HashingUtils::HashString("error"); static const int EXCEPTION_HASH = HashingUtils::HashString("exception"); - + static const int CONTENT_TYPE_APPLICATION_OCTET_STREAM_HASH = HashingUtils::HashString("application/octet-stream"); static const int CONTENT_TYPE_APPLICATION_JSON_HASH = HashingUtils::HashString("application/json"); static const int CONTENT_TYPE_TEXT_PLAIN_HASH = HashingUtils::HashString("text/plain"); - Message::MessageType Message::GetMessageTypeForName(const Aws::String& name) - { - int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str()); - if (hashCode == EVENT_HASH) - { - return MessageType::EVENT; - } - else if (hashCode == ERROR_HASH) - { - return MessageType::REQUEST_LEVEL_ERROR; - } + Message::MessageType Message::GetMessageTypeForName(const Aws::String& name) + { + int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str()); + if (hashCode == EVENT_HASH) + { + return MessageType::EVENT; + } + else if (hashCode == ERROR_HASH) + { + return MessageType::REQUEST_LEVEL_ERROR; + } else if (hashCode == EXCEPTION_HASH) { return MessageType::REQUEST_LEVEL_EXCEPTION; } - else - { - return MessageType::UNKNOWN; - } - } - - Aws::String Message::GetNameForMessageType(MessageType value) - { - switch (value) - { - case MessageType::EVENT: - return "event"; - case MessageType::REQUEST_LEVEL_ERROR: - return "error"; + else + { + return MessageType::UNKNOWN; + } + } + + Aws::String Message::GetNameForMessageType(MessageType value) + { + switch (value) + { + case MessageType::EVENT: + return "event"; + case MessageType::REQUEST_LEVEL_ERROR: + return "error"; case MessageType::REQUEST_LEVEL_EXCEPTION: return "exception"; - default: - return "unknown"; - } - } - + default: + return "unknown"; + } + } + Message::ContentType Message::GetContentTypeForName(const Aws::String& name) { int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str()); @@ -101,32 +101,32 @@ namespace Aws } } - void Message::Reset() - { - m_totalLength = 0; - m_headersLength = 0; - m_payloadLength = 0; - - m_eventHeaders.clear(); - m_eventPayload.clear(); - } - + void Message::Reset() + { + m_totalLength = 0; + m_headersLength = 0; + m_payloadLength = 0; + + m_eventHeaders.clear(); + m_eventPayload.clear(); + } + void Message::WriteEventPayload(const unsigned char* data, size_t length) { std::copy(data, data + length, std::back_inserter(m_eventPayload)); } - void Message::WriteEventPayload(const Aws::Vector<unsigned char>& bits) - { - std::copy(bits.cbegin(), bits.cend(), std::back_inserter(m_eventPayload)); - } - + void Message::WriteEventPayload(const Aws::Vector<unsigned char>& bits) + { + std::copy(bits.cbegin(), bits.cend(), std::back_inserter(m_eventPayload)); + } + void Message::WriteEventPayload(const Aws::String& bits) { std::copy(bits.cbegin(), bits.cend(), std::back_inserter(m_eventPayload)); } - } // namespace Event - } // namespace Utils -} // namespace Aws - + } // namespace Event + } // namespace Utils +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamBuf.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamBuf.cpp index 6a1766bb9f..eb740d9ac0 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamBuf.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamBuf.cpp @@ -1,147 +1,147 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#include <aws/core/utils/event/EventStreamBuf.h> -#include <cassert> - -namespace Aws -{ - namespace Utils - { - namespace Event - { + */ +#include <aws/core/utils/event/EventStreamBuf.h> +#include <cassert> + +namespace Aws +{ + namespace Utils + { + namespace Event + { const size_t DEFAULT_BUF_SIZE = 1024; - EventStreamBuf::EventStreamBuf(EventStreamDecoder& decoder, size_t bufferLength) : - m_byteBuffer(bufferLength), - m_bufferLength(bufferLength), - m_decoder(decoder) - { - assert(decoder); - char* begin = reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()); - char* end = begin + bufferLength - 1; - - setp(begin, end); - setg(begin, begin, begin); - } - - EventStreamBuf::~EventStreamBuf() - { - if (m_decoder) - { - writeToDecoder(); - } - } - - void EventStreamBuf::writeToDecoder() - { - if (pptr() > pbase()) - { - size_t length = static_cast<size_t>(pptr() - pbase()); - m_decoder.Pump(m_byteBuffer, length); - - if (!m_decoder) - { - m_err.write(reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()), length); - } - else - { - pbump(-static_cast<int>(length)); - } - } - } - - std::streampos EventStreamBuf::seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which) - { - if (dir == std::ios_base::beg) - { - return seekpos(off, which); - } - else if (dir == std::ios_base::end) - { - return seekpos(m_bufferLength - 1 - off, which); - } - else if (dir == std::ios_base::cur) - { - if (which == std::ios_base::in) - { - return seekpos((gptr() - (char*)m_byteBuffer.GetUnderlyingData()) + off, which); - } - if (which == std::ios_base::out) - { - return seekpos((pptr() - (char*)m_byteBuffer.GetUnderlyingData()) + off, which); - } - } - - return std::streamoff(-1); - } - - std::streampos EventStreamBuf::seekpos(std::streampos pos, std::ios_base::openmode which) - { - assert(static_cast<size_t>(pos) <= m_bufferLength); - if (static_cast<size_t>(pos) > m_bufferLength) - { - return std::streampos(std::streamoff(-1)); - } - - if (which == std::ios_base::in) - { - m_err.seekg(pos); - return m_err.tellg(); - } - - if (which == std::ios_base::out) - { - return pos; - } - - return std::streampos(std::streamoff(-1)); - } - - int EventStreamBuf::underflow() - { - if (!m_err || m_err.eof() || m_decoder) - { - return std::char_traits<char>::eof(); - } - - m_err.flush(); - m_err.read(reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()), m_byteBuffer.GetLength()); - - char* begin = reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()); - setg(begin, begin, begin + m_err.gcount()); - return std::char_traits<char>::to_int_type(*gptr()); - } - - int EventStreamBuf::overflow(int ch) - { - auto eof = std::char_traits<char>::eof(); - - if (m_decoder) - { - if (ch != eof) - { - *pptr() = (char)ch; - pbump(1); - } - - writeToDecoder(); - return ch; - } - - return eof; - } - - int EventStreamBuf::sync() - { - if (m_decoder) - { - writeToDecoder(); - } - - return 0; - } - } - } -} + EventStreamBuf::EventStreamBuf(EventStreamDecoder& decoder, size_t bufferLength) : + m_byteBuffer(bufferLength), + m_bufferLength(bufferLength), + m_decoder(decoder) + { + assert(decoder); + char* begin = reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()); + char* end = begin + bufferLength - 1; + + setp(begin, end); + setg(begin, begin, begin); + } + + EventStreamBuf::~EventStreamBuf() + { + if (m_decoder) + { + writeToDecoder(); + } + } + + void EventStreamBuf::writeToDecoder() + { + if (pptr() > pbase()) + { + size_t length = static_cast<size_t>(pptr() - pbase()); + m_decoder.Pump(m_byteBuffer, length); + + if (!m_decoder) + { + m_err.write(reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()), length); + } + else + { + pbump(-static_cast<int>(length)); + } + } + } + + std::streampos EventStreamBuf::seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which) + { + if (dir == std::ios_base::beg) + { + return seekpos(off, which); + } + else if (dir == std::ios_base::end) + { + return seekpos(m_bufferLength - 1 - off, which); + } + else if (dir == std::ios_base::cur) + { + if (which == std::ios_base::in) + { + return seekpos((gptr() - (char*)m_byteBuffer.GetUnderlyingData()) + off, which); + } + if (which == std::ios_base::out) + { + return seekpos((pptr() - (char*)m_byteBuffer.GetUnderlyingData()) + off, which); + } + } + + return std::streamoff(-1); + } + + std::streampos EventStreamBuf::seekpos(std::streampos pos, std::ios_base::openmode which) + { + assert(static_cast<size_t>(pos) <= m_bufferLength); + if (static_cast<size_t>(pos) > m_bufferLength) + { + return std::streampos(std::streamoff(-1)); + } + + if (which == std::ios_base::in) + { + m_err.seekg(pos); + return m_err.tellg(); + } + + if (which == std::ios_base::out) + { + return pos; + } + + return std::streampos(std::streamoff(-1)); + } + + int EventStreamBuf::underflow() + { + if (!m_err || m_err.eof() || m_decoder) + { + return std::char_traits<char>::eof(); + } + + m_err.flush(); + m_err.read(reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()), m_byteBuffer.GetLength()); + + char* begin = reinterpret_cast<char*>(m_byteBuffer.GetUnderlyingData()); + setg(begin, begin, begin + m_err.gcount()); + return std::char_traits<char>::to_int_type(*gptr()); + } + + int EventStreamBuf::overflow(int ch) + { + auto eof = std::char_traits<char>::eof(); + + if (m_decoder) + { + if (ch != eof) + { + *pptr() = (char)ch; + pbump(1); + } + + writeToDecoder(); + return ch; + } + + return eof; + } + + int EventStreamBuf::sync() + { + if (m_decoder) + { + writeToDecoder(); + } + + return 0; + } + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamDecoder.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamDecoder.cpp index f70a6c88f6..eeabf140b3 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamDecoder.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamDecoder.cpp @@ -1,170 +1,170 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#include <aws/common/common.h> -#include <aws/core/utils/event/EventHeader.h> -#include <aws/core/utils/event/EventMessage.h> -#include <aws/core/utils/event/EventStreamDecoder.h> -#include <aws/core/utils/logging/LogMacros.h> -#include <aws/core/utils/UnreferencedParam.h> + */ + +#include <aws/common/common.h> +#include <aws/core/utils/event/EventHeader.h> +#include <aws/core/utils/event/EventMessage.h> +#include <aws/core/utils/event/EventStreamDecoder.h> +#include <aws/core/utils/logging/LogMacros.h> +#include <aws/core/utils/UnreferencedParam.h> #include <aws/core/utils/memory/AWSMemory.h> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - static const char EVENT_STREAM_DECODER_CLASS_TAG[] = "Aws::Utils::Event::EventStreamDecoder"; - - EventStreamDecoder::EventStreamDecoder(EventStreamHandler* handler) : m_eventStreamHandler(handler) - { + +namespace Aws +{ + namespace Utils + { + namespace Event + { + static const char EVENT_STREAM_DECODER_CLASS_TAG[] = "Aws::Utils::Event::EventStreamDecoder"; + + EventStreamDecoder::EventStreamDecoder(EventStreamHandler* handler) : m_eventStreamHandler(handler) + { aws_event_stream_streaming_decoder_init(&m_decoder, get_aws_allocator(), - onPayloadSegment, - onPreludeReceived, - onHeaderReceived, - onError, - (void*)handler); - } - - EventStreamDecoder::~EventStreamDecoder() - { - aws_event_stream_streaming_decoder_clean_up(&m_decoder); - } - - void EventStreamDecoder::Pump(const ByteBuffer& data) - { - Pump(data, data.GetLength()); - } - - void EventStreamDecoder::Pump(const ByteBuffer& data, size_t length) - { - aws_byte_buf dataBuf = aws_byte_buf_from_array(static_cast<uint8_t*>(data.GetUnderlyingData()), length); - aws_event_stream_streaming_decoder_pump(&m_decoder, &dataBuf); - } - - void EventStreamDecoder::Reset() - { - m_eventStreamHandler->Reset(); - } - - void EventStreamDecoder::ResetEventStreamHandler(EventStreamHandler* handler) - { + onPayloadSegment, + onPreludeReceived, + onHeaderReceived, + onError, + (void*)handler); + } + + EventStreamDecoder::~EventStreamDecoder() + { + aws_event_stream_streaming_decoder_clean_up(&m_decoder); + } + + void EventStreamDecoder::Pump(const ByteBuffer& data) + { + Pump(data, data.GetLength()); + } + + void EventStreamDecoder::Pump(const ByteBuffer& data, size_t length) + { + aws_byte_buf dataBuf = aws_byte_buf_from_array(static_cast<uint8_t*>(data.GetUnderlyingData()), length); + aws_event_stream_streaming_decoder_pump(&m_decoder, &dataBuf); + } + + void EventStreamDecoder::Reset() + { + m_eventStreamHandler->Reset(); + } + + void EventStreamDecoder::ResetEventStreamHandler(EventStreamHandler* handler) + { aws_event_stream_streaming_decoder_init(&m_decoder, get_aws_allocator(), - onPayloadSegment, - onPreludeReceived, - onHeaderReceived, - onError, - reinterpret_cast<void *>(handler)); - } - - void EventStreamDecoder::onPayloadSegment( - aws_event_stream_streaming_decoder* decoder, - aws_byte_buf* payload, - int8_t isFinalSegment, - void* context) - { - AWS_UNREFERENCED_PARAM(decoder); - auto handler = static_cast<EventStreamHandler*>(context); - assert(handler); - if (!handler) - { - AWS_LOGSTREAM_ERROR(EVENT_STREAM_DECODER_CLASS_TAG, "Payload received, but decoder encountered internal errors before." - "ErrorCode: " << EventStreamErrorsMapper::GetNameForError(handler->GetInternalError()) << ", " - "ErrorMessage: " << handler->GetEventPayloadAsString()); - return; - } - handler->WriteMessageEventPayload(static_cast<unsigned char*>(payload->buffer), payload->len); - - // Complete payload received - if (isFinalSegment == 1) - { - assert(handler->IsMessageCompleted()); - handler->OnEvent(); - handler->Reset(); - } - } - - void EventStreamDecoder::onPreludeReceived( - aws_event_stream_streaming_decoder* decoder, - aws_event_stream_message_prelude* prelude, - void* context) - { - AWS_UNREFERENCED_PARAM(decoder); - auto handler = static_cast<EventStreamHandler*>(context); - handler->Reset(); - - //Encounter internal error in prelude received. - //This error will be handled by OnError callback function later. - if (prelude->total_len < prelude->headers_len + 16) - { - return; - } - handler->SetMessageMetadata(prelude->total_len, prelude->headers_len, - prelude->total_len - prelude->headers_len - 4/*total byte-length*/ - 4/*headers byte-length*/ - 4/*prelude crc*/ - 4/*message crc*/); - AWS_LOGSTREAM_TRACE(EVENT_STREAM_DECODER_CLASS_TAG, "Message received, the expected length of the message is: " << prelude->total_len << - " bytes, and the expected length of the header is: " << prelude->headers_len << " bytes"); - - //Handle empty message - //if (handler->m_message.GetHeadersLength() == 0 && handler->m_message.GetPayloadLength() == 0) - if (handler->IsMessageCompleted()) - { - handler->OnEvent(); - handler->Reset(); - } - } - - void EventStreamDecoder::onHeaderReceived( - aws_event_stream_streaming_decoder* decoder, - aws_event_stream_message_prelude* prelude, - aws_event_stream_header_value_pair* header, - void* context) - { - AWS_UNREFERENCED_PARAM(decoder); - AWS_UNREFERENCED_PARAM(prelude); - auto handler = static_cast<EventStreamHandler*>(context); - assert(handler); - if (!handler) - { - AWS_LOGSTREAM_ERROR(EVENT_STREAM_DECODER_CLASS_TAG, "Payload received, but decoder encountered internal errors before." - "ErrorCode: " << EventStreamErrorsMapper::GetNameForError(handler->GetInternalError()) << ", " - "ErrorMessage: " << handler->GetEventPayloadAsString()); - return; - } - - // The length of a header = 1 byte (to represent the length of header name) + length of header name + 1 byte (to represent header type) - // + 2 bytes (to represent length of header value) + length of header value - handler->InsertMessageEventHeader(Aws::String(header->header_name, header->header_name_len), - 1 + header->header_name_len + 1 + 2 + header->header_value_len, EventHeaderValue(header)); - - // Handle messages only have headers, but without payload. - //if (handler->m_message.GetHeadersLength() == handler->m_headersBytesReceived() && handler->m_message.GetPayloadLength() == 0) - if (handler->IsMessageCompleted()) - { - handler->OnEvent(); - handler->Reset(); - } - } - - void EventStreamDecoder::onError( - aws_event_stream_streaming_decoder* decoder, - aws_event_stream_message_prelude* prelude, - int error_code, - const char* message, - void* context) - { - AWS_UNREFERENCED_PARAM(decoder); - AWS_UNREFERENCED_PARAM(prelude); - auto handler = static_cast<EventStreamHandler*>(context); - handler->SetFailure(); - handler->SetInternalError(error_code); - handler->WriteMessageEventPayload(reinterpret_cast<const unsigned char*>(message), strlen(message)); - handler->OnEvent(); - } - } // namespace Event - } // namespace Utils -} // namespace Aws - + onPayloadSegment, + onPreludeReceived, + onHeaderReceived, + onError, + reinterpret_cast<void *>(handler)); + } + + void EventStreamDecoder::onPayloadSegment( + aws_event_stream_streaming_decoder* decoder, + aws_byte_buf* payload, + int8_t isFinalSegment, + void* context) + { + AWS_UNREFERENCED_PARAM(decoder); + auto handler = static_cast<EventStreamHandler*>(context); + assert(handler); + if (!handler) + { + AWS_LOGSTREAM_ERROR(EVENT_STREAM_DECODER_CLASS_TAG, "Payload received, but decoder encountered internal errors before." + "ErrorCode: " << EventStreamErrorsMapper::GetNameForError(handler->GetInternalError()) << ", " + "ErrorMessage: " << handler->GetEventPayloadAsString()); + return; + } + handler->WriteMessageEventPayload(static_cast<unsigned char*>(payload->buffer), payload->len); + + // Complete payload received + if (isFinalSegment == 1) + { + assert(handler->IsMessageCompleted()); + handler->OnEvent(); + handler->Reset(); + } + } + + void EventStreamDecoder::onPreludeReceived( + aws_event_stream_streaming_decoder* decoder, + aws_event_stream_message_prelude* prelude, + void* context) + { + AWS_UNREFERENCED_PARAM(decoder); + auto handler = static_cast<EventStreamHandler*>(context); + handler->Reset(); + + //Encounter internal error in prelude received. + //This error will be handled by OnError callback function later. + if (prelude->total_len < prelude->headers_len + 16) + { + return; + } + handler->SetMessageMetadata(prelude->total_len, prelude->headers_len, + prelude->total_len - prelude->headers_len - 4/*total byte-length*/ - 4/*headers byte-length*/ - 4/*prelude crc*/ - 4/*message crc*/); + AWS_LOGSTREAM_TRACE(EVENT_STREAM_DECODER_CLASS_TAG, "Message received, the expected length of the message is: " << prelude->total_len << + " bytes, and the expected length of the header is: " << prelude->headers_len << " bytes"); + + //Handle empty message + //if (handler->m_message.GetHeadersLength() == 0 && handler->m_message.GetPayloadLength() == 0) + if (handler->IsMessageCompleted()) + { + handler->OnEvent(); + handler->Reset(); + } + } + + void EventStreamDecoder::onHeaderReceived( + aws_event_stream_streaming_decoder* decoder, + aws_event_stream_message_prelude* prelude, + aws_event_stream_header_value_pair* header, + void* context) + { + AWS_UNREFERENCED_PARAM(decoder); + AWS_UNREFERENCED_PARAM(prelude); + auto handler = static_cast<EventStreamHandler*>(context); + assert(handler); + if (!handler) + { + AWS_LOGSTREAM_ERROR(EVENT_STREAM_DECODER_CLASS_TAG, "Payload received, but decoder encountered internal errors before." + "ErrorCode: " << EventStreamErrorsMapper::GetNameForError(handler->GetInternalError()) << ", " + "ErrorMessage: " << handler->GetEventPayloadAsString()); + return; + } + + // The length of a header = 1 byte (to represent the length of header name) + length of header name + 1 byte (to represent header type) + // + 2 bytes (to represent length of header value) + length of header value + handler->InsertMessageEventHeader(Aws::String(header->header_name, header->header_name_len), + 1 + header->header_name_len + 1 + 2 + header->header_value_len, EventHeaderValue(header)); + + // Handle messages only have headers, but without payload. + //if (handler->m_message.GetHeadersLength() == handler->m_headersBytesReceived() && handler->m_message.GetPayloadLength() == 0) + if (handler->IsMessageCompleted()) + { + handler->OnEvent(); + handler->Reset(); + } + } + + void EventStreamDecoder::onError( + aws_event_stream_streaming_decoder* decoder, + aws_event_stream_message_prelude* prelude, + int error_code, + const char* message, + void* context) + { + AWS_UNREFERENCED_PARAM(decoder); + AWS_UNREFERENCED_PARAM(prelude); + auto handler = static_cast<EventStreamHandler*>(context); + handler->SetFailure(); + handler->SetInternalError(error_code); + handler->WriteMessageEventPayload(reinterpret_cast<const unsigned char*>(message), strlen(message)); + handler->OnEvent(); + } + } // namespace Event + } // namespace Utils +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamEncoder.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamEncoder.cpp index ef7104e839..c7491a3e26 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamEncoder.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamEncoder.cpp @@ -1,162 +1,162 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ - -#include <aws/core/utils/event/EventHeader.h> -#include <aws/core/utils/event/EventMessage.h> -#include <aws/core/utils/event/EventStreamEncoder.h> -#include <aws/core/utils/logging/LogMacros.h> -#include <aws/core/auth/AWSAuthSigner.h> -#include <aws/common/byte_order.h> + */ + +#include <aws/core/utils/event/EventHeader.h> +#include <aws/core/utils/event/EventMessage.h> +#include <aws/core/utils/event/EventStreamEncoder.h> +#include <aws/core/utils/logging/LogMacros.h> +#include <aws/core/auth/AWSAuthSigner.h> +#include <aws/common/byte_order.h> #include <aws/core/utils/memory/AWSMemory.h> - -#include <cassert> - -namespace Aws -{ - namespace Utils - { - namespace Event - { - static const char TAG[] = "EventStreamEncoder"; - - static void EncodeHeaders(const Aws::Utils::Event::Message& msg, aws_array_list* headers) - { + +#include <cassert> + +namespace Aws +{ + namespace Utils + { + namespace Event + { + static const char TAG[] = "EventStreamEncoder"; + + static void EncodeHeaders(const Aws::Utils::Event::Message& msg, aws_array_list* headers) + { aws_array_list_init_dynamic(headers, get_aws_allocator(), msg.GetEventHeaders().size(), sizeof(aws_event_stream_header_value_pair)); - for (auto&& header : msg.GetEventHeaders()) - { - const uint8_t headerKeyLen = static_cast<uint8_t>(header.first.length()); - switch(header.second.GetType()) - { - case EventHeaderValue::EventHeaderType::BOOL_TRUE: - case EventHeaderValue::EventHeaderType::BOOL_FALSE: - aws_event_stream_add_bool_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsBoolean()); - break; - case EventHeaderValue::EventHeaderType::BYTE: - aws_event_stream_add_bool_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsByte()); - break; - case EventHeaderValue::EventHeaderType::INT16: + for (auto&& header : msg.GetEventHeaders()) + { + const uint8_t headerKeyLen = static_cast<uint8_t>(header.first.length()); + switch(header.second.GetType()) + { + case EventHeaderValue::EventHeaderType::BOOL_TRUE: + case EventHeaderValue::EventHeaderType::BOOL_FALSE: + aws_event_stream_add_bool_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsBoolean()); + break; + case EventHeaderValue::EventHeaderType::BYTE: + aws_event_stream_add_bool_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsByte()); + break; + case EventHeaderValue::EventHeaderType::INT16: aws_event_stream_add_int16_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsInt16()); - break; - case EventHeaderValue::EventHeaderType::INT32: + break; + case EventHeaderValue::EventHeaderType::INT32: aws_event_stream_add_int32_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsInt32()); - break; - case EventHeaderValue::EventHeaderType::INT64: + break; + case EventHeaderValue::EventHeaderType::INT64: aws_event_stream_add_int64_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsInt64()); - break; - case EventHeaderValue::EventHeaderType::BYTE_BUF: - { - const auto& bytes = header.second.GetEventHeaderValueAsBytebuf(); + break; + case EventHeaderValue::EventHeaderType::BYTE_BUF: + { + const auto& bytes = header.second.GetEventHeaderValueAsBytebuf(); aws_event_stream_add_bytebuf_header(headers, header.first.c_str(), headerKeyLen, bytes.GetUnderlyingData(), static_cast<uint16_t>(bytes.GetLength()), 1 /*copy*/); - } - break; - case EventHeaderValue::EventHeaderType::STRING: - { - const auto& bytes = header.second.GetUnderlyingBuffer(); - aws_event_stream_add_string_header(headers, header.first.c_str(), headerKeyLen, reinterpret_cast<char*>(bytes.GetUnderlyingData()), static_cast<uint16_t>(bytes.GetLength()), 0 /*copy*/); - } - break; - case EventHeaderValue::EventHeaderType::TIMESTAMP: + } + break; + case EventHeaderValue::EventHeaderType::STRING: + { + const auto& bytes = header.second.GetUnderlyingBuffer(); + aws_event_stream_add_string_header(headers, header.first.c_str(), headerKeyLen, reinterpret_cast<char*>(bytes.GetUnderlyingData()), static_cast<uint16_t>(bytes.GetLength()), 0 /*copy*/); + } + break; + case EventHeaderValue::EventHeaderType::TIMESTAMP: aws_event_stream_add_timestamp_header(headers, header.first.c_str(), headerKeyLen, header.second.GetEventHeaderValueAsTimestamp()); - break; - case EventHeaderValue::EventHeaderType::UUID: - { - ByteBuffer uuidBytes = header.second.GetEventHeaderValueAsUuid(); - aws_event_stream_add_uuid_header(headers, header.first.c_str(), headerKeyLen, uuidBytes.GetUnderlyingData()); - } - break; - default: - AWS_LOG_ERROR(TAG, "Encountered unknown type of header."); - break; - } - } - } - - EventStreamEncoder::EventStreamEncoder(Client::AWSAuthSigner* signer) : m_signer(signer) - { - } - - - Aws::Vector<unsigned char> EventStreamEncoder::EncodeAndSign(const Aws::Utils::Event::Message& msg) - { - aws_event_stream_message encoded = Encode(msg); - aws_event_stream_message signedMessage = Sign(&encoded); - - const auto signedMessageLength = signedMessage.message_buffer ? aws_event_stream_message_total_length(&signedMessage) : 0; - - Aws::Vector<unsigned char> outputBits(signedMessage.message_buffer, signedMessage.message_buffer + signedMessageLength); - aws_event_stream_message_clean_up(&encoded); - aws_event_stream_message_clean_up(&signedMessage); - return outputBits; - } - - aws_event_stream_message EventStreamEncoder::Encode(const Aws::Utils::Event::Message& msg) - { - aws_array_list headers; - EncodeHeaders(msg, &headers); - - aws_byte_buf payload; - payload.len = msg.GetEventPayload().size(); - // this const_cast is OK because aws_byte_buf will only be "read from" by the following functions. - payload.buffer = const_cast<uint8_t*>(msg.GetEventPayload().data()); - payload.capacity = 0; - payload.allocator = nullptr; - - aws_event_stream_message encoded; + break; + case EventHeaderValue::EventHeaderType::UUID: + { + ByteBuffer uuidBytes = header.second.GetEventHeaderValueAsUuid(); + aws_event_stream_add_uuid_header(headers, header.first.c_str(), headerKeyLen, uuidBytes.GetUnderlyingData()); + } + break; + default: + AWS_LOG_ERROR(TAG, "Encountered unknown type of header."); + break; + } + } + } + + EventStreamEncoder::EventStreamEncoder(Client::AWSAuthSigner* signer) : m_signer(signer) + { + } + + + Aws::Vector<unsigned char> EventStreamEncoder::EncodeAndSign(const Aws::Utils::Event::Message& msg) + { + aws_event_stream_message encoded = Encode(msg); + aws_event_stream_message signedMessage = Sign(&encoded); + + const auto signedMessageLength = signedMessage.message_buffer ? aws_event_stream_message_total_length(&signedMessage) : 0; + + Aws::Vector<unsigned char> outputBits(signedMessage.message_buffer, signedMessage.message_buffer + signedMessageLength); + aws_event_stream_message_clean_up(&encoded); + aws_event_stream_message_clean_up(&signedMessage); + return outputBits; + } + + aws_event_stream_message EventStreamEncoder::Encode(const Aws::Utils::Event::Message& msg) + { + aws_array_list headers; + EncodeHeaders(msg, &headers); + + aws_byte_buf payload; + payload.len = msg.GetEventPayload().size(); + // this const_cast is OK because aws_byte_buf will only be "read from" by the following functions. + payload.buffer = const_cast<uint8_t*>(msg.GetEventPayload().data()); + payload.capacity = 0; + payload.allocator = nullptr; + + aws_event_stream_message encoded; if(aws_event_stream_message_init(&encoded, get_aws_allocator(), &headers, &payload) == AWS_OP_ERR) - { + { AWS_LOGSTREAM_ERROR(TAG, "Error creating event-stream message from payload."); aws_event_stream_headers_list_cleanup(&headers); - // GCC 4.9.4 issues a warning with -Wextra if we simply do - // return {}; - aws_event_stream_message empty{nullptr, nullptr, 0}; - return empty; - } + // GCC 4.9.4 issues a warning with -Wextra if we simply do + // return {}; + aws_event_stream_message empty{nullptr, nullptr, 0}; + return empty; + } aws_event_stream_headers_list_cleanup(&headers); - return encoded; - } - - aws_event_stream_message EventStreamEncoder::Sign(aws_event_stream_message* msg) - { - const auto msglen = msg->message_buffer ? aws_event_stream_message_total_length(msg) : 0; - Event::Message signedMessage; - signedMessage.WriteEventPayload(msg->message_buffer, msglen); - - assert(m_signer); - if (!m_signer->SignEventMessage(signedMessage, m_signatureSeed)) - { - AWS_LOGSTREAM_ERROR(TAG, "Failed to sign event message frame."); - // GCC 4.9.4 issues a warning with -Wextra if we simply do - // return {}; - aws_event_stream_message empty{nullptr, nullptr, 0}; - return empty; - } - - aws_array_list headers; - EncodeHeaders(signedMessage, &headers); - - aws_byte_buf payload; - payload.len = signedMessage.GetEventPayload().size(); - payload.buffer = signedMessage.GetEventPayload().data(); - payload.capacity = 0; - payload.allocator = nullptr; - - aws_event_stream_message signedmsg; + return encoded; + } + + aws_event_stream_message EventStreamEncoder::Sign(aws_event_stream_message* msg) + { + const auto msglen = msg->message_buffer ? aws_event_stream_message_total_length(msg) : 0; + Event::Message signedMessage; + signedMessage.WriteEventPayload(msg->message_buffer, msglen); + + assert(m_signer); + if (!m_signer->SignEventMessage(signedMessage, m_signatureSeed)) + { + AWS_LOGSTREAM_ERROR(TAG, "Failed to sign event message frame."); + // GCC 4.9.4 issues a warning with -Wextra if we simply do + // return {}; + aws_event_stream_message empty{nullptr, nullptr, 0}; + return empty; + } + + aws_array_list headers; + EncodeHeaders(signedMessage, &headers); + + aws_byte_buf payload; + payload.len = signedMessage.GetEventPayload().size(); + payload.buffer = signedMessage.GetEventPayload().data(); + payload.capacity = 0; + payload.allocator = nullptr; + + aws_event_stream_message signedmsg; if(aws_event_stream_message_init(&signedmsg, get_aws_allocator(), &headers, &payload)) - { + { AWS_LOGSTREAM_ERROR(TAG, "Error creating event-stream message from payload."); aws_event_stream_headers_list_cleanup(&headers); - // GCC 4.9.4 issues a warning with -Wextra if we simply do - // return {}; - aws_event_stream_message empty{nullptr, nullptr, 0}; - return empty; - } + // GCC 4.9.4 issues a warning with -Wextra if we simply do + // return {}; + aws_event_stream_message empty{nullptr, nullptr, 0}; + return empty; + } aws_event_stream_headers_list_cleanup(&headers); - return signedmsg; - } - - } // namespace Event - } // namespace Utils -} // namespace Aws - + return signedmsg; + } + + } // namespace Event + } // namespace Utils +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamErrors.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamErrors.cpp index 836d0b47c5..df999b07b8 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamErrors.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventStreamErrors.cpp @@ -1,66 +1,66 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#include <aws/core/client/AWSError.h> -#include <aws/core/utils/HashingUtils.h> -#include <aws/core/utils/event/EventStreamErrors.h> - - using namespace Aws::Client; -// using namespace Aws::S3; -// using namespace Aws::Utils; - -namespace Aws -{ - namespace Utils - { - namespace Event - { - namespace EventStreamErrorsMapper - { - /* - static const int EVENT_STREAM_NO_ERROR_HASH = HashingUtils::HashString("EventStreamNoError"); - static const int EVENT_STREAM_BUFFER_LENGTH_MISMATCH_HASH = HashingUtils::HashString("EventStreamBufferLengthMismatch"); - static const int EVENT_STREAM_INSUFFICIENT_BUFFER_LEN_HASH = HashingUtils::HashString("EventStreamInsufficientBufferLen"); - static const int EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED_HASH = HashingUtils::HashString("EventStreamMessageFieldSizeExceeded"); - static const int EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamPreludeChecksumFailure"); - static const int EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamMessageChecksumFailure"); - static const int EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN_HASH = HashingUtils::HashString("EventStreamMessageInvalidHeadersLen"); - static const int EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE_HASH = HashingUtils::HashString("EventStreamMessageUnknownHeaderType"); - static const int EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE_HASH = HashingUtils::HashString("EventStreamMessageParserIllegalState"); - */ - const char* GetNameForError(EventStreamErrors error) - { - switch (error) - { - case EventStreamErrors::EVENT_STREAM_NO_ERROR: - return "EventStreamNoError"; - case EventStreamErrors::EVENT_STREAM_BUFFER_LENGTH_MISMATCH: - return "EventStreamBufferLengthMismatch"; - case EventStreamErrors::EVENT_STREAM_INSUFFICIENT_BUFFER_LEN: - return "EventStreamInsufficientBufferLen"; - case EventStreamErrors::EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED: - return "EventStreamMessageFieldSizeExceeded"; - case EventStreamErrors::EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE: - return "EventStreamPreludeChecksumFailure"; - case EventStreamErrors::EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE: - return "EventStreamMessageChecksumFailure"; - case EventStreamErrors::EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN: - return "EventStreamMessageInvalidHeadersLen"; - case EventStreamErrors::EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE: - return "EventStreamMessageUnknownHeaderType"; - case EventStreamErrors::EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE: - return "EventStreamMessageParserIllegalState"; - default: - return "EventStreamUnknownError"; - } - } - - AWSError<CoreErrors> GetAwsErrorForEventStreamError(EventStreamErrors error) - { - return AWSError<CoreErrors>(CoreErrors::UNKNOWN, GetNameForError(error), "", false); - } - } // namespace EventStreamErrorsMapper - } // namespace Event - } // namespace Utils -} // namespace Aws + */ +#include <aws/core/client/AWSError.h> +#include <aws/core/utils/HashingUtils.h> +#include <aws/core/utils/event/EventStreamErrors.h> + + using namespace Aws::Client; +// using namespace Aws::S3; +// using namespace Aws::Utils; + +namespace Aws +{ + namespace Utils + { + namespace Event + { + namespace EventStreamErrorsMapper + { + /* + static const int EVENT_STREAM_NO_ERROR_HASH = HashingUtils::HashString("EventStreamNoError"); + static const int EVENT_STREAM_BUFFER_LENGTH_MISMATCH_HASH = HashingUtils::HashString("EventStreamBufferLengthMismatch"); + static const int EVENT_STREAM_INSUFFICIENT_BUFFER_LEN_HASH = HashingUtils::HashString("EventStreamInsufficientBufferLen"); + static const int EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED_HASH = HashingUtils::HashString("EventStreamMessageFieldSizeExceeded"); + static const int EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamPreludeChecksumFailure"); + static const int EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamMessageChecksumFailure"); + static const int EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN_HASH = HashingUtils::HashString("EventStreamMessageInvalidHeadersLen"); + static const int EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE_HASH = HashingUtils::HashString("EventStreamMessageUnknownHeaderType"); + static const int EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE_HASH = HashingUtils::HashString("EventStreamMessageParserIllegalState"); + */ + const char* GetNameForError(EventStreamErrors error) + { + switch (error) + { + case EventStreamErrors::EVENT_STREAM_NO_ERROR: + return "EventStreamNoError"; + case EventStreamErrors::EVENT_STREAM_BUFFER_LENGTH_MISMATCH: + return "EventStreamBufferLengthMismatch"; + case EventStreamErrors::EVENT_STREAM_INSUFFICIENT_BUFFER_LEN: + return "EventStreamInsufficientBufferLen"; + case EventStreamErrors::EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED: + return "EventStreamMessageFieldSizeExceeded"; + case EventStreamErrors::EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE: + return "EventStreamPreludeChecksumFailure"; + case EventStreamErrors::EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE: + return "EventStreamMessageChecksumFailure"; + case EventStreamErrors::EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN: + return "EventStreamMessageInvalidHeadersLen"; + case EventStreamErrors::EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE: + return "EventStreamMessageUnknownHeaderType"; + case EventStreamErrors::EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE: + return "EventStreamMessageParserIllegalState"; + default: + return "EventStreamUnknownError"; + } + } + + AWSError<CoreErrors> GetAwsErrorForEventStreamError(EventStreamErrors error) + { + return AWSError<CoreErrors>(CoreErrors::UNKNOWN, GetNameForError(error), "", false); + } + } // namespace EventStreamErrorsMapper + } // namespace Event + } // namespace Utils +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp index 9b785d1995..a0f5400612 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp @@ -633,7 +633,7 @@ Aws::String JsonView::WriteCompact(bool treatAsObject) const { return "{}"; } - return {}; + return {}; } auto temp = cJSON_PrintUnformatted(m_value); @@ -650,7 +650,7 @@ Aws::String JsonView::WriteReadable(bool treatAsObject) const { return "{\n}\n"; } - return {}; + return {}; } auto temp = cJSON_Print(m_value); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp index 3f59dbe96d..0ba47bd92c 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/ConcurrentStreamBuf.cpp @@ -1,109 +1,109 @@ /** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. - */ -#include <aws/core/utils/stream/ConcurrentStreamBuf.h> -#include <aws/core/utils/logging/LogMacros.h> -#include <cstdint> -#include <cassert> - -namespace Aws -{ - namespace Utils - { - namespace Stream - { - const char TAG[] = "ConcurrentStreamBuf"; - ConcurrentStreamBuf::ConcurrentStreamBuf(size_t bufferLength) : - m_putArea(bufferLength), // we access [0] of the put area below so we must initialize it. - m_eof(false) - { - m_getArea.reserve(bufferLength); - m_backbuf.reserve(bufferLength); - - char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); - setp(pbegin, pbegin + bufferLength); - } - - void ConcurrentStreamBuf::SetEof() - { - { - std::unique_lock<std::mutex> lock(m_lock); - m_eof = true; - } - m_signal.notify_all(); - } - - void ConcurrentStreamBuf::FlushPutArea() - { - const size_t bitslen = pptr() - pbase(); - if (bitslen) - { - // scope the lock - { - std::unique_lock<std::mutex> lock(m_lock); + */ +#include <aws/core/utils/stream/ConcurrentStreamBuf.h> +#include <aws/core/utils/logging/LogMacros.h> +#include <cstdint> +#include <cassert> + +namespace Aws +{ + namespace Utils + { + namespace Stream + { + const char TAG[] = "ConcurrentStreamBuf"; + ConcurrentStreamBuf::ConcurrentStreamBuf(size_t bufferLength) : + m_putArea(bufferLength), // we access [0] of the put area below so we must initialize it. + m_eof(false) + { + m_getArea.reserve(bufferLength); + m_backbuf.reserve(bufferLength); + + char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); + setp(pbegin, pbegin + bufferLength); + } + + void ConcurrentStreamBuf::SetEof() + { + { + std::unique_lock<std::mutex> lock(m_lock); + m_eof = true; + } + m_signal.notify_all(); + } + + void ConcurrentStreamBuf::FlushPutArea() + { + const size_t bitslen = pptr() - pbase(); + if (bitslen) + { + // scope the lock + { + std::unique_lock<std::mutex> lock(m_lock); m_signal.wait(lock, [this, bitslen]{ return m_eof || bitslen <= (m_backbuf.capacity() - m_backbuf.size()); }); if (m_eof) { return; } - std::copy(pbase(), pptr(), std::back_inserter(m_backbuf)); - } - m_signal.notify_one(); - char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); - setp(pbegin, pbegin + m_putArea.size()); - } - } - - std::streampos ConcurrentStreamBuf::seekoff(std::streamoff, std::ios_base::seekdir, std::ios_base::openmode) - { - return std::streamoff(-1); // Seeking is not supported. - } - - std::streampos ConcurrentStreamBuf::seekpos(std::streampos, std::ios_base::openmode) - { - return std::streamoff(-1); // Seeking is not supported. - } - - int ConcurrentStreamBuf::underflow() - { - { - std::unique_lock<std::mutex> lock(m_lock); - m_signal.wait(lock, [this]{ return m_backbuf.empty() == false || m_eof; }); - - if (m_eof && m_backbuf.empty()) - { - return std::char_traits<char>::eof(); - } - - m_getArea.clear(); // keep the get-area from growing unbounded. - std::copy(m_backbuf.begin(), m_backbuf.end(), std::back_inserter(m_getArea)); - m_backbuf.clear(); - } - m_signal.notify_one(); - char* gbegin = reinterpret_cast<char*>(&m_getArea[0]); - setg(gbegin, gbegin, gbegin + m_getArea.size()); - return std::char_traits<char>::to_int_type(*gptr()); - } - - std::streamsize ConcurrentStreamBuf::showmanyc() - { - std::unique_lock<std::mutex> lock(m_lock); - AWS_LOGSTREAM_TRACE(TAG, "stream how many character? " << m_backbuf.size()); - return m_backbuf.size(); - } - - int ConcurrentStreamBuf::overflow(int ch) - { - const auto eof = std::char_traits<char>::eof(); - - if (ch == eof) - { - FlushPutArea(); - return eof; - } - - FlushPutArea(); + std::copy(pbase(), pptr(), std::back_inserter(m_backbuf)); + } + m_signal.notify_one(); + char* pbegin = reinterpret_cast<char*>(&m_putArea[0]); + setp(pbegin, pbegin + m_putArea.size()); + } + } + + std::streampos ConcurrentStreamBuf::seekoff(std::streamoff, std::ios_base::seekdir, std::ios_base::openmode) + { + return std::streamoff(-1); // Seeking is not supported. + } + + std::streampos ConcurrentStreamBuf::seekpos(std::streampos, std::ios_base::openmode) + { + return std::streamoff(-1); // Seeking is not supported. + } + + int ConcurrentStreamBuf::underflow() + { + { + std::unique_lock<std::mutex> lock(m_lock); + m_signal.wait(lock, [this]{ return m_backbuf.empty() == false || m_eof; }); + + if (m_eof && m_backbuf.empty()) + { + return std::char_traits<char>::eof(); + } + + m_getArea.clear(); // keep the get-area from growing unbounded. + std::copy(m_backbuf.begin(), m_backbuf.end(), std::back_inserter(m_getArea)); + m_backbuf.clear(); + } + m_signal.notify_one(); + char* gbegin = reinterpret_cast<char*>(&m_getArea[0]); + setg(gbegin, gbegin, gbegin + m_getArea.size()); + return std::char_traits<char>::to_int_type(*gptr()); + } + + std::streamsize ConcurrentStreamBuf::showmanyc() + { + std::unique_lock<std::mutex> lock(m_lock); + AWS_LOGSTREAM_TRACE(TAG, "stream how many character? " << m_backbuf.size()); + return m_backbuf.size(); + } + + int ConcurrentStreamBuf::overflow(int ch) + { + const auto eof = std::char_traits<char>::eof(); + + if (ch == eof) + { + FlushPutArea(); + return eof; + } + + FlushPutArea(); { std::unique_lock<std::mutex> lock(m_lock); if (m_eof) @@ -114,13 +114,13 @@ namespace Aws pbump(1); return ch; } - } - - int ConcurrentStreamBuf::sync() - { - FlushPutArea(); - return 0; - } - } - } -} + } + + int ConcurrentStreamBuf::sync() + { + FlushPutArea(); + return 0; + } + } + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp index f656fc8613..7aaf9c82f3 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/PreallocatedStreamBuf.cpp @@ -16,8 +16,8 @@ namespace Aws PreallocatedStreamBuf::PreallocatedStreamBuf(unsigned char* buffer, uint64_t lengthToRead) : m_underlyingBuffer(buffer), m_lengthToRead(lengthToRead) { - char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); - char* begin = reinterpret_cast<char*>(m_underlyingBuffer); + char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); + char* begin = reinterpret_cast<char*>(m_underlyingBuffer); setp(begin, end); setg(begin, begin, end); } @@ -55,12 +55,12 @@ namespace Aws return pos_type(off_type(-1)); } - char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); - char* begin = reinterpret_cast<char*>(m_underlyingBuffer); + char* end = reinterpret_cast<char*>(m_underlyingBuffer + m_lengthToRead); + char* begin = reinterpret_cast<char*>(m_underlyingBuffer); if (which == std::ios_base::in) { - setg(begin, begin + static_cast<size_t>(pos), end); + setg(begin, begin + static_cast<size_t>(pos), end); } if (which == std::ios_base::out) @@ -72,4 +72,4 @@ namespace Aws } } } -} +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp index 6e42994744..91064590a8 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/stream/SimpleStreamBuf.cpp @@ -201,7 +201,7 @@ std::streamsize SimpleStreamBuf::xsputn(const char* s, std::streamsize n) return writeCount; } -Aws::String SimpleStreamBuf::str() const +Aws::String SimpleStreamBuf::str() const { return Aws::String(m_buffer, pptr()); } @@ -236,4 +236,4 @@ void SimpleStreamBuf::str(const Aws::String& value) } } -} +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/xml/XmlSerializer.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/xml/XmlSerializer.cpp index c06befaf9b..59d259a911 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/xml/XmlSerializer.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/xml/XmlSerializer.cpp @@ -125,7 +125,7 @@ Aws::String XmlNode::GetText() const return printer.CStr(); } - return {}; + return {}; } void XmlNode::SetText(const Aws::String& textValue) diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/ya.make b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/ya.make index d6b0823d45..9ff0428036 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/ya.make +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/ya.make @@ -41,13 +41,13 @@ CFLAGS( -DAWS_SDK_VERSION_MINOR=8 -DAWS_SDK_VERSION_PATCH=113 -DAWS_USE_EPOLL - -DCURL_HAS_H2 + -DCURL_HAS_H2 -DCURL_HAS_TLS_PROXY -DENABLE_CURL_CLIENT -DENABLE_CURL_LOGGING -DENABLE_OPENSSL_ENCRYPTION - -DHAS_PATHCONF - -DHAS_UMASK + -DHAS_PATHCONF + -DHAS_UMASK -DS2N_ADX -DS2N_CPUID_AVAILABLE -DS2N_HAVE_EXECINFO @@ -126,12 +126,12 @@ SRCS( source/utils/crypto/openssl/CryptoImpl.cpp source/utils/event/EventDecoderStream.cpp source/utils/event/EventEncoderStream.cpp - source/utils/event/EventHeader.cpp - source/utils/event/EventMessage.cpp - source/utils/event/EventStreamBuf.cpp - source/utils/event/EventStreamDecoder.cpp - source/utils/event/EventStreamEncoder.cpp - source/utils/event/EventStreamErrors.cpp + source/utils/event/EventHeader.cpp + source/utils/event/EventMessage.cpp + source/utils/event/EventStreamBuf.cpp + source/utils/event/EventStreamDecoder.cpp + source/utils/event/EventStreamEncoder.cpp + source/utils/event/EventStreamErrors.cpp source/utils/json/JsonSerializer.cpp source/utils/logging/AWSLogging.cpp source/utils/logging/ConsoleLogSystem.cpp @@ -140,7 +140,7 @@ SRCS( source/utils/logging/LogLevel.cpp source/utils/memory/AWSMemory.cpp source/utils/memory/stl/SimpleStringStream.cpp - source/utils/stream/ConcurrentStreamBuf.cpp + source/utils/stream/ConcurrentStreamBuf.cpp source/utils/stream/PreallocatedStreamBuf.cpp source/utils/stream/ResponseStream.cpp source/utils/stream/SimpleStreamBuf.cpp |