replace std::tolower with Azure::Core::ToLower (#834)
This commit is contained in:
parent
d904267489
commit
08e364e1cd
@ -8,6 +8,7 @@
|
||||
#include "azure/core/http/pipeline.hpp"
|
||||
#include "azure/core/nullable.hpp"
|
||||
#include "azure/core/response.hpp"
|
||||
#include "azure/core/strings.hpp"
|
||||
#include "azure/storage/common/crypt.hpp"
|
||||
#include "azure/storage/common/storage_common.hpp"
|
||||
#include "azure/storage/common/storage_error.hpp"
|
||||
@ -3473,11 +3474,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -3703,11 +3700,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -6029,11 +6022,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -6203,11 +6192,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -6401,11 +6386,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -7140,11 +7121,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -7560,11 +7537,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -7931,11 +7904,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
@ -9016,11 +8985,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::set<std::string> metadataKeys;
|
||||
for (const auto& pair : options.Metadata)
|
||||
{
|
||||
std::string key = pair.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
if (metadataKeys.insert(key).second == false)
|
||||
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
|
||||
{
|
||||
throw std::runtime_error("duplicate keys in metadata");
|
||||
}
|
||||
|
||||
@ -17,17 +17,18 @@ namespace Azure { namespace Storage {
|
||||
string_to_sign += Azure::Core::Http::HttpMethodToString(request.GetMethod()) + "\n";
|
||||
|
||||
const auto& headers = request.GetHeaders();
|
||||
for (std::string headerName : {"Content-Encoding",
|
||||
"Content-Language",
|
||||
"Content-Length",
|
||||
"Content-MD5",
|
||||
"Content-Type",
|
||||
"Date",
|
||||
"If-Modified-Since",
|
||||
"If-Match",
|
||||
"If-None-Match",
|
||||
"If-Unmodified-Since",
|
||||
"Range"})
|
||||
for (std::string headerName :
|
||||
{"Content-Encoding",
|
||||
"Content-Language",
|
||||
"Content-Length",
|
||||
"Content-MD5",
|
||||
"Content-Type",
|
||||
"Date",
|
||||
"If-Modified-Since",
|
||||
"If-Match",
|
||||
"If-None-Match",
|
||||
"If-Unmodified-Since",
|
||||
"Range"})
|
||||
{
|
||||
auto ite = headers.find(Azure::Core::Strings::ToLower(headerName));
|
||||
if (ite != headers.end())
|
||||
@ -51,10 +52,7 @@ namespace Azure { namespace Storage {
|
||||
ite != headers.end() && ite->first.substr(0, prefix.length()) == prefix;
|
||||
++ite)
|
||||
{
|
||||
std::string key = ite->first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](char c) {
|
||||
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
});
|
||||
std::string key = Azure::Core::Strings::ToLower(ite->first);
|
||||
ordered_kv.emplace_back(std::make_pair(std::move(key), ite->second));
|
||||
}
|
||||
std::sort(ordered_kv.begin(), ordered_kv.end());
|
||||
@ -68,10 +66,7 @@ namespace Azure { namespace Storage {
|
||||
string_to_sign += "/" + m_credential->AccountName + "/" + request.GetUrl().GetPath() + "\n";
|
||||
for (const auto& query : request.GetUrl().GetQueryParameters())
|
||||
{
|
||||
std::string key = query.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), [](char c) {
|
||||
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
});
|
||||
std::string key = Azure::Core::Strings::ToLower(query.first);
|
||||
ordered_kv.emplace_back(std::make_pair(
|
||||
Azure::Core::Http::Url::Decode(key), Azure::Core::Http::Url::Decode(query.second)));
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "azure/core/http/http.hpp"
|
||||
#include "azure/core/strings.hpp"
|
||||
|
||||
namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
@ -163,10 +164,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
std::string LowercaseRandomString(size_t size)
|
||||
{
|
||||
auto str = RandomString(size);
|
||||
std::transform(
|
||||
str.begin(), str.end(), str.begin(), [](unsigned char c) { return char(std::tolower(c)); });
|
||||
return str;
|
||||
return Azure::Core::Strings::ToLower(RandomString(size));
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> RandomMetadata(size_t size)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user