]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/message.cpp
Fix header name normalization logic
[libs/net.git] / source / http / message.cpp
index 21d2c4b5a4ee955d7e8cd24177347ecedcd5f25d..b86f95495eb267639bbc1bdf9ee58662dd198bf1 100644 (file)
@@ -97,7 +97,7 @@ unsigned Message::parse_content(const string &d)
 
 unsigned Message::parse_headers(const string &d)
 {
-       unsigned start = 0;
+       string::size_type start = 0;
        while(1)
        {
                string::size_type lf = d.find('\n', start);
@@ -106,7 +106,7 @@ unsigned Message::parse_headers(const string &d)
                if(lf==start || (d[start]=='\r' && lf==start+1))
                        return lf+1;
 
-               unsigned colon = d.find(':', start);
+               string::size_type colon = d.find(':', start);
                if(colon>lf)
                        throw invalid_argument("Message::parse_headers");
 
@@ -135,13 +135,13 @@ string Message::normalize_header_name(const string &hdr) const
        bool upper = true;
        for(string::iterator i=result.begin(); i!=result.end(); ++i)
        {
-               if(upper)
+               if(*i=='-')
+                       upper = true;
+               else if(upper)
                {
                        *i = toupper(*i);
                        upper = false;
                }
-               else if(*i=='-')
-                       upper = true;
                else
                        *i = tolower(*i);
        }