Fix const naming in Core to follow Guidelines (#1481)

* Fix grammar in doxygen comments

* Update constants to follow the Guidelines
  Remove 'c_' prefixes
This commit is contained in:
Rick Winter 2021-01-27 11:56:30 -08:00 committed by GitHub
parent a2bfa7acf1
commit 453d39c577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 37 deletions

View File

@ -168,9 +168,9 @@ std::unique_ptr<RawResponse> CurlTransport::Send(Context const& context, Request
// Try to send the request. If we get CURLE_UNSUPPORTED_PROTOCOL back, it means the connection is
// either closed or the socket is not usable any more. In that case, let the session be destroyed
// and create a new session to get another connection from connection pool.
// Prevent from trying forever by using c_DefaultMaxOpenNewConnectionIntentsAllowed.
// Prevent from trying forever by using DefaultMaxOpenNewConnectionIntentsAllowed.
for (auto getConnectionOpenIntent = 0;
getConnectionOpenIntent < Details::c_DefaultMaxOpenNewConnectionIntentsAllowed;
getConnectionOpenIntent < Details::DefaultMaxOpenNewConnectionIntentsAllowed;
getConnectionOpenIntent++)
{
performing = session->Perform(context);
@ -396,7 +396,7 @@ CURLcode CurlSession::UploadBody(Context const& context)
if (uploadChunkSize <= 0)
{
// use default size
uploadChunkSize = Details::c_DefaultUploadChunkSize;
uploadChunkSize = Details::DefaultUploadChunkSize;
}
auto unique_buffer = std::make_unique<uint8_t[]>(static_cast<size_t>(uploadChunkSize));
@ -489,7 +489,7 @@ void CurlSession::ParseChunkSize(Context const& context)
* indicate the the next read call should read from the inner buffer start.
*/
this->m_innerBufferSize = m_connection->ReadFromSocket(
context, this->m_readBuffer, Details::c_DefaultLibcurlReaderSize);
context, this->m_readBuffer, Details::DefaultLibcurlReaderSize);
this->m_bodyStartInBuffer = 0;
}
else
@ -509,7 +509,7 @@ void CurlSession::ParseChunkSize(Context const& context)
if (keepPolling)
{ // Read all internal buffer and \n was not found, pull from wire
this->m_innerBufferSize = m_connection->ReadFromSocket(
context, this->m_readBuffer, Details::c_DefaultLibcurlReaderSize);
context, this->m_readBuffer, Details::DefaultLibcurlReaderSize);
this->m_bodyStartInBuffer = 0;
}
}
@ -545,7 +545,7 @@ void CurlSession::ReadStatusLineAndHeadersFromRawResponse(
// Try to fill internal buffer from socket.
// If response is smaller than buffer, we will get back the size of the response
bufferSize = m_connection->ReadFromSocket(
context, this->m_readBuffer, Details::c_DefaultLibcurlReaderSize);
context, this->m_readBuffer, Details::DefaultLibcurlReaderSize);
if (bufferSize == 0)
{
// closed connection, prevent application from keep trying to pull more bytes from the wire
@ -607,7 +607,7 @@ void CurlSession::ReadStatusLineAndHeadersFromRawResponse(
if (this->m_bodyStartInBuffer == -1)
{ // if nothing on inner buffer, pull from wire
this->m_innerBufferSize = m_connection->ReadFromSocket(
context, this->m_readBuffer, Details::c_DefaultLibcurlReaderSize);
context, this->m_readBuffer, Details::DefaultLibcurlReaderSize);
this->m_bodyStartInBuffer = 0;
}
@ -630,7 +630,7 @@ void CurlSession::ReadExpected(Context const& context, uint8_t expected)
{
// end of buffer, pull data from wire
this->m_innerBufferSize = m_connection->ReadFromSocket(
context, this->m_readBuffer, Details::c_DefaultLibcurlReaderSize);
context, this->m_readBuffer, Details::DefaultLibcurlReaderSize);
this->m_bodyStartInBuffer = 0;
}
auto data = this->m_readBuffer[this->m_bodyStartInBuffer];
@ -1135,7 +1135,7 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (!newHandle)
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host + ". "
Details::DefaultFailedToGetNewConnectionTemplate + host + ". "
+ std::string("curl_easy_init returned Null"));
}
CURLcode result;
@ -1144,14 +1144,14 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (!SetLibcurlOption(newHandle, CURLOPT_URL, request.GetUrl().GetAbsoluteUrl().data(), &result))
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host + ". "
Details::DefaultFailedToGetNewConnectionTemplate + host + ". "
+ std::string(curl_easy_strerror(result)));
}
if (!SetLibcurlOption(newHandle, CURLOPT_CONNECT_ONLY, 1L, &result))
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host + ". "
Details::DefaultFailedToGetNewConnectionTemplate + host + ". "
+ std::string(curl_easy_strerror(result)));
}
@ -1161,7 +1161,7 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (!SetLibcurlOption(newHandle, CURLOPT_TIMEOUT, 60L * 60L * 24L, &result))
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host + ". "
Details::DefaultFailedToGetNewConnectionTemplate + host + ". "
+ std::string(curl_easy_strerror(result)));
}
@ -1173,7 +1173,7 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (!SetLibcurlOption(newHandle, CURLOPT_PROXY, options.Proxy.c_str(), &result))
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host + ". Failed to set proxy to:"
Details::DefaultFailedToGetNewConnectionTemplate + host + ". Failed to set proxy to:"
+ options.Proxy + ". " + std::string(curl_easy_strerror(result)));
}
}
@ -1183,7 +1183,7 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (!SetLibcurlOption(newHandle, CURLOPT_CAINFO, options.CAInfo.c_str(), &result))
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host + ". Failed to set CA cert to:"
Details::DefaultFailedToGetNewConnectionTemplate + host + ". Failed to set CA cert to:"
+ options.CAInfo + ". " + std::string(curl_easy_strerror(result)));
}
}
@ -1197,7 +1197,7 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (!SetLibcurlOption(newHandle, CURLOPT_SSL_OPTIONS, sslOption, &result))
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host
Details::DefaultFailedToGetNewConnectionTemplate + host
+ ". Failed to set ssl options to long bitmask:" + std::to_string(sslOption) + ". "
+ std::string(curl_easy_strerror(result)));
}
@ -1207,7 +1207,7 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (!SetLibcurlOption(newHandle, CURLOPT_SSL_VERIFYPEER, 0L, &result))
{
throw Azure::Core::Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host
Details::DefaultFailedToGetNewConnectionTemplate + host
+ ". Failed to disable ssl verify peer." + ". "
+ std::string(curl_easy_strerror(result)));
}
@ -1217,7 +1217,7 @@ std::unique_ptr<CurlNetworkConnection> CurlConnectionPool::GetCurlConnection(
if (performResult != CURLE_OK)
{
throw Http::TransportException(
Details::c_DefaultFailedToGetNewConnectionTemplate + host + ". "
Details::DefaultFailedToGetNewConnectionTemplate + host + ". "
+ std::string(curl_easy_strerror(performResult)));
}
@ -1263,7 +1263,7 @@ void CurlConnectionPool::CleanUp()
{
// wait before trying to clean
std::this_thread::sleep_for(
std::chrono::milliseconds(Details::c_DefaultCleanerIntervalMilliseconds));
std::chrono::milliseconds(Details::DefaultCleanerIntervalMilliseconds));
{
// take mutex for reading the pool

View File

@ -20,16 +20,16 @@ namespace Azure { namespace Core { namespace Http {
namespace Details {
// libcurl CURL_MAX_WRITE_SIZE is 64k. Using same value for default uploading chunk size.
// This can be customizable in the HttpRequest
constexpr static int64_t c_DefaultUploadChunkSize = 1024 * 64;
constexpr static auto c_DefaultLibcurlReaderSize = 1024;
constexpr static int64_t DefaultUploadChunkSize = 1024 * 64;
constexpr static auto DefaultLibcurlReaderSize = 1024;
// Run time error template
constexpr static const char* c_DefaultFailedToGetNewConnectionTemplate
constexpr static const char* DefaultFailedToGetNewConnectionTemplate
= "Fail to get a new connection for: ";
constexpr static int c_DefaultMaxOpenNewConnectionIntentsAllowed = 10;
constexpr static int DefaultMaxOpenNewConnectionIntentsAllowed = 10;
// 90 sec -> cleaner wait time before next clean routine
constexpr static int c_DefaultCleanerIntervalMilliseconds = 1000 * 90;
constexpr static int DefaultCleanerIntervalMilliseconds = 1000 * 90;
// 60 sec -> expired connection is when it waits for 60 sec or more and it's not re-used
constexpr static int c_DefaultConnectionExpiredMilliseconds = 1000 * 60;
constexpr static int DefaultConnectionExpiredMilliseconds = 1000 * 60;
} // namespace Details
/**
@ -142,7 +142,7 @@ namespace Azure { namespace Core { namespace Http {
{
auto connectionOnWaitingTimeMs = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - this->m_lastUseTime);
return connectionOnWaitingTimeMs.count() >= Details::c_DefaultConnectionExpiredMilliseconds;
return connectionOnWaitingTimeMs.count() >= Details::DefaultConnectionExpiredMilliseconds;
}
/**

View File

@ -247,7 +247,7 @@ namespace Azure { namespace Core { namespace Http {
* from wire into it, it can be holding less then N bytes.
*
*/
int64_t m_innerBufferSize = Details::c_DefaultLibcurlReaderSize;
int64_t m_innerBufferSize = Details::DefaultLibcurlReaderSize;
bool m_isChunkedResponseType = false;
@ -277,7 +277,7 @@ namespace Azure { namespace Core { namespace Http {
* provide their own buffer to copy from socket when reading the HTTP body using streams.
*
*/
uint8_t m_readBuffer[Details::c_DefaultLibcurlReaderSize]
uint8_t m_readBuffer[Details::DefaultLibcurlReaderSize]
= {0}; // to work with libcurl custom read.
/**

View File

@ -47,7 +47,7 @@ int main() {
#endif
const unsigned char c_LocaleInvariantLowercaseTable[256] = {
const unsigned char LocaleInvariantLowercaseTable[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
@ -71,7 +71,7 @@ namespace Azure { namespace Core { namespace Internal { namespace Strings {
unsigned char ToLower(const unsigned char symbol) noexcept
{
return c_LocaleInvariantLowercaseTable[symbol];
return LocaleInvariantLowercaseTable[symbol];
}
std::string const ToLower(const std::string& src) noexcept
@ -92,8 +92,8 @@ namespace Azure { namespace Core { namespace Internal { namespace Strings {
rhs.begin(),
rhs.end(),
[](const char left, const char right) noexcept {
return c_LocaleInvariantLowercaseTable[static_cast<unsigned char>(left)]
== c_LocaleInvariantLowercaseTable[static_cast<unsigned char>(right)];
return LocaleInvariantLowercaseTable[static_cast<unsigned char>(left)]
== LocaleInvariantLowercaseTable[static_cast<unsigned char>(right)];
});
}

View File

@ -25,7 +25,7 @@
namespace Azure { namespace Core { namespace Test {
namespace Datails {
constexpr int64_t c_fileSize = 1024 * 100;
constexpr int64_t FileSize = 1024 * 100;
}
TEST_P(TransportAdapter, get)
@ -457,11 +457,11 @@ namespace Azure { namespace Core { namespace Test {
#error "Unknown platform"
#endif
auto requestBodyStream
= Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::c_fileSize);
= Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::FileSize);
auto request = Azure::Core::Http::Request(
Azure::Core::Http::HttpMethod::Put, host, &requestBodyStream, true);
// Make transport adapter to read all stream content for uploading instead of chunks
request.SetUploadChunkSize(Azure::Core::Test::Datails::c_fileSize);
request.SetUploadChunkSize(Azure::Core::Test::Datails::FileSize);
{
auto response = m_pipeline->Send(Azure::Core::GetApplicationContext(), request);
checkResponseCode(response->GetStatusCode());
@ -496,7 +496,7 @@ namespace Azure { namespace Core { namespace Test {
#endif
auto requestBodyStream
= Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::c_fileSize);
= Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::FileSize);
auto request = Azure::Core::Http::Request(
Azure::Core::Http::HttpMethod::Put, host, &requestBodyStream, true);
// Make transport adapter to read default chunk size
@ -534,11 +534,11 @@ namespace Azure { namespace Core { namespace Test {
#endif
auto requestBodyStream
= Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::c_fileSize);
= Azure::Core::Http::FileBodyStream(f, 0, Azure::Core::Test::Datails::FileSize);
auto request = Azure::Core::Http::Request(
Azure::Core::Http::HttpMethod::Put, host, &requestBodyStream, true);
// Make transport adapter to read more than file size (5Mb)
request.SetUploadChunkSize(Azure::Core::Test::Datails::c_fileSize * 5);
request.SetUploadChunkSize(Azure::Core::Test::Datails::FileSize * 5);
{
auto response = m_pipeline->Send(Azure::Core::GetApplicationContext(), request);
checkResponseCode(response->GetStatusCode());