]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/message.cpp
Prefer range-based for loops where possible
[libs/net.git] / source / http / message.cpp
index b86f95495eb267639bbc1bdf9ee58662dd198bf1..2ae0ff80a641e3f133f051c37fe66569e6a93944 100644 (file)
@@ -120,9 +120,9 @@ string Message::str_common() const
 {
        string result;
 
-       for(HeaderMap::const_iterator i=headers.begin(); i!=headers.end(); ++i)
-               if(i->first[0]!='-')
-                       result += format("%s: %s\r\n", i->first, i->second);
+       for(auto &kvp: headers)
+               if(kvp.first[0]!='-')
+                       result += format("%s: %s\r\n", kvp.first, kvp.second);
        result += "\r\n";
        result += content;
 
@@ -133,17 +133,17 @@ string Message::normalize_header_name(const string &hdr) const
 {
        string result = hdr;
        bool upper = true;
-       for(string::iterator i=result.begin(); i!=result.end(); ++i)
+       for(char &c: result)
        {
-               if(*i=='-')
+               if(c=='-')
                        upper = true;
                else if(upper)
                {
-                       *i = toupper(*i);
+                       c = toupper(static_cast<unsigned char>(c));
                        upper = false;
                }
                else
-                       *i = tolower(*i);
+                       c = tolower(static_cast<unsigned char>(c));
        }
        return result;
 }