]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/message.cpp
Use the auto type to shorten long declarations
[libs/net.git] / source / http / message.cpp
index 92321e8a87bd4c953f039141724c621c2d977ac2..99d149725c80db88f5c534547369da8ddac90401 100644 (file)
@@ -48,7 +48,7 @@ unsigned Message::parse_content(const string &d)
        if(complete)
                return 0;
 
-       HeaderMap::const_iterator i = headers.find("Content-Length");
+       auto i = headers.find("Content-Length");
        if(i!=headers.end())
        {
                string::size_type needed = lexical_cast<string::size_type>(i->second)-content.size();
@@ -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(upper)
+               if(c=='-')
+                       upper = true;
+               else if(upper)
                {
-                       *i = toupper(*i);
+                       c = toupper(static_cast<unsigned char>(c));
                        upper = false;
                }
-               else if(*i=='-')
-                       upper = true;
                else
-                       *i = tolower(*i);
+                       c = tolower(static_cast<unsigned char>(c));
        }
        return result;
 }