]> granicus.if.org Git - pdns/commitdiff
YaHTTP: Don't shadow variables
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 20 Feb 2017 10:20:57 +0000 (11:20 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 20 Feb 2017 10:20:57 +0000 (11:20 +0100)
Merged upstream in 2fb4d972176d25e0de4875141e3f28a4b12bba6b.

ext/yahttp/yahttp/cookie.hpp
ext/yahttp/yahttp/exception.hpp
ext/yahttp/yahttp/reqresp.cpp
ext/yahttp/yahttp/reqresp.hpp
ext/yahttp/yahttp/router.cpp

index b99b21e0104136644c643ccf9fb4c5b9640e3e92..dd5433580dbb4859e37446028e5abd215515d79f 100644 (file)
@@ -66,7 +66,7 @@ namespace YaHTTP {
     } //<! key value pair parser
   
     void parseCookieHeader(const std::string &cookiestr) {
-      std::list<Cookie> cookies;
+      std::list<Cookie> lcookies;
       int cstate = 0; //cookiestate
       size_t pos,npos;
       pos = 0;
@@ -91,22 +91,22 @@ namespace YaHTTP {
           if (s == "expires") {
             DateTime dt;
             dt.parseCookie(value);
-            for(std::list<Cookie>::iterator i = cookies.begin(); i != cookies.end(); i++)
+            for(std::list<Cookie>::iterator i = lcookies.begin(); i != lcookies.end(); i++)
               i->expires = dt;
           } else if (s == "domain") {
-            for(std::list<Cookie>::iterator i = cookies.begin(); i != cookies.end(); i++)
+            for(std::list<Cookie>::iterator i = lcookies.begin(); i != lcookies.end(); i++)
               i->domain = value;
           } else if (s == "path") {
-            for(std::list<Cookie>::iterator i = cookies.begin(); i != cookies.end(); i++)
+            for(std::list<Cookie>::iterator i = lcookies.begin(); i != lcookies.end(); i++)
               i->path = value;
           }
         } else if (cookiestr.compare(pos, 8, "httpOnly")==0) {
           cstate = 1;
-          for(std::list<Cookie>::iterator i = cookies.begin(); i != cookies.end(); i++)
+          for(std::list<Cookie>::iterator i = lcookies.begin(); i != lcookies.end(); i++)
             i->httponly = true;
         } else if (cookiestr.compare(pos, 6, "secure")  ==0) {
           cstate = 1;
-          for(std::list<Cookie>::iterator i = cookies.begin(); i != cookies.end(); i++)
+          for(std::list<Cookie>::iterator i = lcookies.begin(); i != lcookies.end(); i++)
             i->secure = true;
         } else if (cstate == 0) { // expect cookie
           Cookie c;
@@ -123,7 +123,7 @@ namespace YaHTTP {
           keyValuePair(s, c.name, c.value);
           c.name = YaHTTP::Utility::decodeURL(c.name);
           c.value = YaHTTP::Utility::decodeURL(c.value);
-          cookies.push_back(c);
+          lcookies.push_back(c);
         } else if (cstate == 1) {
           // ignore crap
           break;
@@ -131,7 +131,7 @@ namespace YaHTTP {
       }
   
       // store cookies
-      for(std::list<Cookie>::iterator i = cookies.begin(); i != cookies.end(); i++) {
+      for(std::list<Cookie>::iterator i = lcookies.begin(); i != lcookies.end(); i++) {
         this->cookies[i->name] = *i;
       }
     }; //<! Parse multiple cookies from header 
index 2d7afbf5dcc11fa76be0ef80153b316c53fb4414..72a048a328c187405f729257f4a3ee37f1cf3862 100644 (file)
@@ -8,7 +8,7 @@ namespace YaHTTP {
   class Error: public std::exception {
   public:
     Error() {};
-    Error(const std::string& reason): reason(reason) {};
+    Error(const std::string& reason_): reason(reason_) {};
     virtual ~Error() throw() {};
 
     virtual const char* what() const throw()
@@ -21,7 +21,7 @@ namespace YaHTTP {
   class ParseError: public YaHTTP::Error {
   public:
     ParseError() {};
-    ParseError(const std::string& reason): Error(reason) {};
+    ParseError(const std::string& reason_): Error(reason_) {};
   };
 };
 
index cc992859bea859ccb3686c501b24078de55d16b2..be0612a90f176101d88710c8e4ebd4d8ccf9d1ab 100644 (file)
@@ -61,17 +61,17 @@ namespace YaHTTP {
         }
       } else if (state == 1) {
         std::string key,value;
-        size_t pos;
+        size_t pos1;
         if (line.empty()) {
           chunked = (target->headers.find("transfer-encoding") != target->headers.end() && target->headers["transfer-encoding"] == "chunked");
           state = 2;
           break;
         }
         // split headers
-        if ((pos = line.find(": ")) == std::string::npos)
+        if ((pos1 = line.find(": ")) == std::string::npos)
           throw ParseError("Malformed header line");
-        key = line.substr(0, pos);
-        value = line.substr(pos+2);
+        key = line.substr(0, pos1);
+        value = line.substr(pos1+2);
         for(std::string::iterator it=key.begin(); it != key.end(); it++)
           if (std::isspace(*it))
             throw ParseError("Header key contains whitespace which is not allowed by RFC");
@@ -86,11 +86,11 @@ namespace YaHTTP {
         } else {
           if (key == "host" && target->kind == YAHTTP_TYPE_REQUEST) {
             // maybe it contains port?
-            if ((pos = value.find(":")) == std::string::npos) {
+            if ((pos1 = value.find(":")) == std::string::npos) {
               target->url.host = value;
             } else {
-              target->url.host = value.substr(0, pos);
-              target->url.port = ::atoi(value.substr(pos).c_str());
+              target->url.host = value.substr(0, pos1);
+              target->url.port = ::atoi(value.substr(pos1).c_str());
             }
           }
           if (target->headers.find(key) != target->headers.end()) {
index 78882dd8e78babc79544da135f8ed0cbca8d247b..5637e444213e1b26a9edb38398db65954e601455 100644 (file)
@@ -65,8 +65,8 @@ namespace YaHTTP {
     /* Simple sendfile renderer which streams file to ostream */
     class SendFileRender {
     public:
-      SendFileRender(const std::string& path) {
-        this->path = path;
+      SendFileRender(const std::string& path_) {
+        this->path = path_;
       };
   
       size_t operator()(const HTTPBase *doc __attribute__((unused)), std::ostream& os, bool chunked) const {
@@ -174,8 +174,8 @@ public:
     strstr_map_t& POST() { return postvars; }; //<! accessor for postvars
     strcookie_map_t& COOKIES() { return jar.cookies; }; //<! accessor for cookies
 
-    std::string versionStr(int version) const {
-      switch(version) {
+    std::string versionStr(int version_) const {
+      switch(version_) {
       case  9: return "0.9";
       case 10: return "1.0";
       case 11: return "1.1";
@@ -244,10 +244,10 @@ public:
       this->jar = rhs.jar;
       this->version = rhs.version;
     }
-    void setup(const std::string& method, const std::string& url) {
-      this->url.parse(url);
+    void setup(const std::string& method_, const std::string& url_) {
+      this->url.parse(url_);
       this->headers["host"] = this->url.host;
-      this->method = method;
+      this->method = method_;
       std::transform(this->method.begin(), this->method.end(), this->method.begin(), ::toupper);
       this->headers["user-agent"] = "YaHTTP v1.0";
     }; //<! Set some initial things for a request
@@ -301,10 +301,10 @@ public:
 
     void keyValuePair(const std::string &keyvalue, std::string &key, std::string &value); //<! key value pair parser helper
 
-    void initialize(T* target) {
+    void initialize(T* target_) {
       chunked = false; chunk_size = 0;
       bodybuf.str(""); minbody = 0; maxbody = 0;
-      pos = 0; state = 0; this->target = target
+      pos = 0; state = 0; this->target = target_;
       hasBody = false;
       buffer = "";
       this->target->initialize();
@@ -322,8 +322,8 @@ public:
     void finalize() {
       bodybuf.flush();
       if (ready()) {
-        strstr_map_t::iterator pos = target->headers.find("content-type");
-        if (pos != target->headers.end() && Utility::iequals(pos->second, "application/x-www-form-urlencoded", 32)) {
+        strstr_map_t::iterator cpos = target->headers.find("content-type");
+        if (cpos != target->headers.end() && Utility::iequals(cpos->second, "application/x-www-form-urlencoded", 32)) {
           target->postvars = Utility::parseUrlParameters(bodybuf.str());
         }
         target->body = bodybuf.str();
index 3678000eaea84edd1f103b52c840d18f1f2fcb04..a92be62b6022b1460b42112a24d935e2bd1ef402 100644 (file)
@@ -27,7 +27,6 @@ namespace YaHTTP {
   bool Router::route(Request *req, THandlerFunction& handler) {
     std::map<std::string, TDelim> params;
     int pos1,pos2;
-    std::string pname;
     bool matched = false;
     std::string rname;