From 190a0e80b1b47e9363cb75da10f2609896de3ebc Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Tue, 6 Oct 2020 16:10:42 -0700 Subject: [PATCH] fixing typos from #686 (#704) Follow up from #686 to address PR comments about typos --- .../inc/azure/core/http/curl/curl.hpp | 2 +- sdk/core/azure-core/src/http/curl/curl.cpp | 59 +++++++++++-------- sdk/core/azure-core/test/e2e/azure_hang.cpp | 2 + 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp b/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp index 0936e4784..e2bb15d22 100644 --- a/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp @@ -526,7 +526,7 @@ namespace Azure { namespace Core { namespace Http { } /** - * @brief function to log + * @brief The function to log. * */ std::function m_logger; diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 2a2bd0243..058f53dd9 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -54,7 +54,6 @@ int pollSocketUntilEventOrTimeout( #ifndef POSIX #ifndef WINDOWS // platform does not support Poll(). - // TODO. Legacy select() for other platforms? throw Azure::Core::Http::TransportException( "Error while sending request. Platform does not support Poll()"); #endif @@ -86,10 +85,12 @@ int pollSocketUntilEventOrTimeout( } #ifdef WINDOWS -// Windows needs this after every write to socket or peformance would be reduced to 1/4 for +// Windows needs this after every write to socket or performance would be reduced to 1/4 for // uploading operation. // https://github.com/Azure/azure-sdk-for-cpp/issues/644 -void WinSocketSetBuffSize(curl_socket_t socket, std::function logger) +void WinSocketSetBuffSize( + curl_socket_t socket, + std::function logger) { ULONG ideal; DWORD ideallen; @@ -97,11 +98,13 @@ void WinSocketSetBuffSize(curl_socket_t socket, std::functionGetResponse(); // Move the ownership of the CurlSession (bodyStream) to the response @@ -315,19 +320,21 @@ CURLcode CurlSession::SendBuffer(uint8_t const* buffer, size_t bufferSize) switch (sendResult) { - case CURLE_OK: { + case CURLE_OK: + { sentBytesTotal += sentBytesPerRequest; this->m_uploadedBytes += sentBytesPerRequest; break; } - case CURLE_AGAIN: { + case CURLE_AGAIN: + { // start polling operation auto pollUntilSocketIsReady = pollSocketUntilEventOrTimeout( this->m_curlSocket, PollSocketDirection::Write, 60000L); if (pollUntilSocketIsReady == 0) { - throw Azure::Core::Http::TransportException("Timeout waitting for socket to upload."); + throw Azure::Core::Http::TransportException("Timeout waiting for socket to upload."); } else if (pollUntilSocketIsReady < 0) { // negative value, error while polling @@ -338,7 +345,8 @@ CURLcode CurlSession::SendBuffer(uint8_t const* buffer, size_t bufferSize) // Ready to continue download. break; } - default: { + default: + { return sendResult; } } @@ -494,7 +502,7 @@ void CurlSession::ReadStatusLineAndHeadersFromRawResponse(bool reUseInternalBUff // For Head request, set the length of body response to 0. // Response will give us content-length as if we were not doing Head saying what would it be the // length of the body. However, Server won't send body - // For NoContent status code, also need to set conentLength to 0. + // For NoContent status code, also need to set contentLength to 0. // https://github.com/Azure/azure-sdk-for-cpp/issues/406 if (this->m_request.GetMethod() == HttpMethod::Head || this->m_lastStatusCode == Azure::Core::Http::HttpStatusCode::NoContent) @@ -504,7 +512,7 @@ void CurlSession::ReadStatusLineAndHeadersFromRawResponse(bool reUseInternalBUff return; } - // headers are already loweCase at this point + // headers are already lowerCase at this point auto headers = this->m_response->GetHeaders(); auto isContentLengthHeaderInResponse = headers.find("content-length"); @@ -615,7 +623,7 @@ int64_t CurlSession::Read(Azure::Core::Context const& context, uint8_t* buffer, if (this->m_bodyStartInBuffer == this->m_innerBufferSize) { - this->m_bodyStartInBuffer = -1; // read everyting from inner buffer already + this->m_bodyStartInBuffer = -1; // read everything from inner buffer already } return totalRead; } @@ -664,7 +672,8 @@ int64_t CurlSession::ReadFromSocket(uint8_t* buffer, int64_t bufferSize) switch (readResult) { - case CURLE_AGAIN: { + case CURLE_AGAIN: + { // start polling operation auto pollUntilSocketIsReady = pollSocketUntilEventOrTimeout(this->m_curlSocket, PollSocketDirection::Read, 60000L); @@ -681,10 +690,12 @@ int64_t CurlSession::ReadFromSocket(uint8_t* buffer, int64_t bufferSize) // Ready to continue download. break; } - case CURLE_OK: { + case CURLE_OK: + { break; } - default: { + default: + { // Error reading from socket throw Azure::Core::Http::TransportException( "Error while reading from network socket. CURLE code: " + std::to_string(readResult) @@ -848,7 +859,7 @@ int64_t CurlSession::ResponseBufferParser::BuildStatusCode( if (this->m_internalBuffer.size() > 0) { // If the index is same as buffer it means delimiter is at position 0, meaning that - // internalBuffer containst the status line and we don't need to add anything else + // internalBuffer contains the status line and we don't need to add anything else if (indexOfEndOfStatusLine > buffer) { // Append and build response minus the delimiter @@ -896,7 +907,7 @@ int64_t CurlSession::ResponseBufferParser::BuildHeader( // advance { // move offset one possition. This is because readStatusLine and readHeader will read up to - // '\r' then next delimeter is '\n' and we don't care + // '\r' then next delimiter is '\n' and we don't care start = buffer + 1; } @@ -923,7 +934,7 @@ int64_t CurlSession::ResponseBufferParser::BuildHeader( if (this->m_internalBuffer.size() > 0) { // If the index is same as buffer it means delimiter is at position 0, meaning that - // internalBuffer containst the status line and we don't need to add anything else + // internalBuffer contains the status line and we don't need to add anything else if (indexOfEndOfStatusLine > buffer) { // Append and build response minus the delimiter @@ -990,7 +1001,7 @@ std::unique_ptr CurlConnectionPool::GetCurlConnection(Request& r // No available connection for the pool for the required host. Create one auto newConnection = std::make_unique(host); - // Libcurl setup before open connection (url, connet_only, timeout) + // Libcurl setup before open connection (url, connect_only, timeout) SetLibcurlOption( newConnection->GetHandle(), CURLOPT_URL, @@ -1033,7 +1044,7 @@ void CurlConnectionPool::MoveConnectionBackToPool( // laststatusCode = 0 if (code < 200 || code >= 300) { - // A hanlder with previos response with Error can't be re-use. + // A handler with previous response with Error can't be re-use. return; } diff --git a/sdk/core/azure-core/test/e2e/azure_hang.cpp b/sdk/core/azure-core/test/e2e/azure_hang.cpp index 7b3e82033..72b399e4c 100644 --- a/sdk/core/azure-core/test/e2e/azure_hang.cpp +++ b/sdk/core/azure-core/test/e2e/azure_hang.cpp @@ -8,6 +8,8 @@ */ #ifdef _MSC_VER +// this option is used to allow the application to use std::getenv without getting a compilation +// warning about it on MSVC. #define _CRT_SECURE_NO_WARNINGS #endif