From 432713c4d1b5ffbef0f8c7f813bc24eea612e22b Mon Sep 17 00:00:00 2001 From: Haiqi Xu <14502009+haiqi96@users.noreply.github.com> Date: Wed, 14 Aug 2024 00:04:42 -0400 Subject: [PATCH] Apply review comments --- .../core/src/clp/aws/AwsAuthenticationSigner.cpp | 13 ++++++------- .../core/src/clp/aws/AwsAuthenticationSigner.hpp | 1 + components/core/src/clp/aws/constants.hpp | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/core/src/clp/aws/AwsAuthenticationSigner.cpp b/components/core/src/clp/aws/AwsAuthenticationSigner.cpp index 71566dc41..36479ef62 100644 --- a/components/core/src/clp/aws/AwsAuthenticationSigner.cpp +++ b/components/core/src/clp/aws/AwsAuthenticationSigner.cpp @@ -9,10 +9,10 @@ #include #include #include +#include #include "../ErrorCode.hpp" #include "../hash_utils.hpp" -#include "../string_utils/string_utils.hpp" #include "../type_utils.hpp" #include "constants.hpp" @@ -173,17 +173,16 @@ S3Url::S3Url(string const& url) { }; boost::smatch match; - string end_point; if (boost::regex_match(url, match, host_style_url_regex)) { m_region = match["region"]; m_bucket = match["bucket"]; m_key = match["key"]; - end_point = match["endpoint"]; + m_end_point = match["endpoint"]; } else if (boost::regex_match(url, match, path_style_url_regex)) { m_region = match["region"]; m_bucket = match["bucket"]; m_key = match["key"]; - end_point = match["endpoint"]; + m_end_point = match["endpoint"]; } else { throw OperationFailed( ErrorCode_BadParam, @@ -193,19 +192,19 @@ S3Url::S3Url(string const& url) { ); } - if ("amazonaws.com" != end_point) { + if (cAwsEndpoint != m_end_point) { throw OperationFailed( ErrorCode_BadParam, __FILENAME__, __LINE__, - "Invalid S3 endpoint: " + end_point + "Invalid S3 endpoint: " + m_end_point ); } if (m_region.empty()) { m_region = cDefaultRegion; } - m_host = fmt::format("{}.s3.{}.{}", m_bucket, m_region, end_point); + m_host = fmt::format("{}.s3.{}.{}", m_bucket, m_region, m_end_point); } auto AwsAuthenticationSigner::generate_presigned_url( diff --git a/components/core/src/clp/aws/AwsAuthenticationSigner.hpp b/components/core/src/clp/aws/AwsAuthenticationSigner.hpp index 77142e960..bf1c64dfe 100644 --- a/components/core/src/clp/aws/AwsAuthenticationSigner.hpp +++ b/components/core/src/clp/aws/AwsAuthenticationSigner.hpp @@ -53,6 +53,7 @@ class S3Url { private: std::string m_region; + std::string m_end_point; std::string m_bucket; std::string m_key; std::string m_host; diff --git a/components/core/src/clp/aws/constants.hpp b/components/core/src/clp/aws/constants.hpp index dd5032df7..caebe92a1 100644 --- a/components/core/src/clp/aws/constants.hpp +++ b/components/core/src/clp/aws/constants.hpp @@ -4,6 +4,9 @@ #include namespace clp::aws { +// Endpoint +constexpr std::string_view cAwsEndpoint{"amazonaws.com"}; + // Query String Parameter Names constexpr std::string_view cXAmzAlgorithm{"X-Amz-Algorithm"}; constexpr std::string_view cXAmzCredential{"X-Amz-Credential"};