Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/DefaultWebRequestCurl.cpp

Issue 29391775: Issue 5013 - Improve some const-correctness (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Feedback + another small patch related. Created March 22, 2017, 4:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/DefaultWebRequestCurl.cpp
===================================================================
--- a/src/DefaultWebRequestCurl.cpp
+++ b/src/DefaultWebRequestCurl.cpp
@@ -139,32 +139,29 @@ AdblockPlus::ServerResponse AdblockPlus:
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ReceiveData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &responseText);
// Request compressed data. Using any supported aglorithm
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, ReceiveHeader);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headerData);
struct curl_slist* headerList = 0;
- for (HeaderList::const_iterator it = requestHeaders.begin();
- it != requestHeaders.end(); ++it)
+ for (const auto& header : requestHeaders)
{
- headerList = curl_slist_append(headerList, (it->first + ": " + it->second).c_str());
+ headerList = curl_slist_append(headerList, (header.first + ": " + header.second).c_str());
}
if (headerList)
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerList);
result.status = ConvertErrorCode(curl_easy_perform(curl));
result.responseStatus = headerData.status;
result.responseText = responseText.str();
- for (std::vector<std::string>::iterator it = headerData.headers.begin();
- it != headerData.headers.end(); ++it)
+ for (const auto& header : headerData.headers)
{
// Parse header name and value out of something like "Foo: bar"
- std::string header = *it;
size_t colonPos = header.find(':');
if (colonPos != std::string::npos)
{
size_t nameStart = 0;
size_t nameEnd = colonPos;
while (nameEnd > nameStart && isspace(header[nameEnd - 1]))
nameEnd--;

Powered by Google App Engine
This is Rietveld