summaryrefslogtreecommitdiff
path: root/src/httpfetch.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-20 19:37:29 +0200
committerGitHub <noreply@github.com>2017-08-20 19:37:29 +0200
commitae9b5e00989756bb676429530dfe81039009001c (patch)
tree119c9ac4b886c24d42f418e21e4175a942eb95ff /src/httpfetch.cpp
parentc8d3d1133945138108aa195e6b3c93b07c6e4fa0 (diff)
downloadminetest-ae9b5e00989756bb676429530dfe81039009001c.tar.gz
minetest-ae9b5e00989756bb676429530dfe81039009001c.tar.bz2
minetest-ae9b5e00989756bb676429530dfe81039009001c.zip
Modernize code: very last fixes (#6290)
Last modernization fixes
Diffstat (limited to 'src/httpfetch.cpp')
-rw-r--r--src/httpfetch.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/httpfetch.cpp b/src/httpfetch.cpp
index cd66a80d5..c6419a5d6 100644
--- a/src/httpfetch.cpp
+++ b/src/httpfetch.cpp
@@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sstream>
#include <list>
#include <map>
-#include <errno.h>
+#include <cerrno>
#include <mutex>
#include "threading/event.h"
#include "config.h"
@@ -170,7 +170,8 @@ class CurlHandlePool
std::list<CURL*> handles;
public:
- CurlHandlePool() {}
+ CurlHandlePool() = default;
+
~CurlHandlePool()
{
for (std::list<CURL*>::iterator it = handles.begin();
@@ -272,7 +273,7 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_,
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS,
request.connect_timeout);
- if (request.useragent != "")
+ if (!request.useragent.empty())
curl_easy_setopt(curl, CURLOPT_USERAGENT, request.useragent.c_str());
// Set up a write callback that writes to the
@@ -308,13 +309,12 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_,
} else if (request.post_data.empty()) {
curl_easy_setopt(curl, CURLOPT_POST, 1);
std::string str;
- for (StringMap::iterator it = request.post_fields.begin();
- it != request.post_fields.end(); ++it) {
- if (str != "")
+ for (auto &post_field : request.post_fields) {
+ if (!str.empty())
str += "&";
- str += urlencode(it->first);
+ str += urlencode(post_field.first);
str += "=";
- str += urlencode(it->second);
+ str += urlencode(post_field.second);
}
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
str.size());
@@ -330,9 +330,8 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_,
// modified until CURLOPT_POSTFIELDS is cleared
}
// Set additional HTTP headers
- for (std::vector<std::string>::iterator it = request.extra_headers.begin();
- it != request.extra_headers.end(); ++it) {
- http_header = curl_slist_append(http_header, it->c_str());
+ for (const std::string &extra_header : request.extra_headers) {
+ http_header = curl_slist_append(http_header, extra_header.c_str());
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, http_header);
@@ -708,8 +707,8 @@ protected:
}
// Call curl_multi_remove_handle and cleanup easy handles
- for (size_t i = 0; i < m_all_ongoing.size(); ++i) {
- delete m_all_ongoing[i];
+ for (HTTPFetchOngoing *i : m_all_ongoing) {
+ delete i;
}
m_all_ongoing.clear();