From: Remi Gacogne Date: Mon, 20 Feb 2017 10:20:57 +0000 (+0100) Subject: YaHTTP: Don't shadow variables X-Git-Tag: rec-4.1.0-alpha1~265^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3850df7a56255a9a2db09aa11a104c26634c4efc;p=pdns YaHTTP: Don't shadow variables Merged upstream in 2fb4d972176d25e0de4875141e3f28a4b12bba6b. --- diff --git a/ext/yahttp/yahttp/cookie.hpp b/ext/yahttp/yahttp/cookie.hpp index b99b21e01..dd5433580 100644 --- a/ext/yahttp/yahttp/cookie.hpp +++ b/ext/yahttp/yahttp/cookie.hpp @@ -66,7 +66,7 @@ namespace YaHTTP { } // cookies; + std::list 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::iterator i = cookies.begin(); i != cookies.end(); i++) + for(std::list::iterator i = lcookies.begin(); i != lcookies.end(); i++) i->expires = dt; } else if (s == "domain") { - for(std::list::iterator i = cookies.begin(); i != cookies.end(); i++) + for(std::list::iterator i = lcookies.begin(); i != lcookies.end(); i++) i->domain = value; } else if (s == "path") { - for(std::list::iterator i = cookies.begin(); i != cookies.end(); i++) + for(std::list::iterator i = lcookies.begin(); i != lcookies.end(); i++) i->path = value; } } else if (cookiestr.compare(pos, 8, "httpOnly")==0) { cstate = 1; - for(std::list::iterator i = cookies.begin(); i != cookies.end(); i++) + for(std::list::iterator i = lcookies.begin(); i != lcookies.end(); i++) i->httponly = true; } else if (cookiestr.compare(pos, 6, "secure") ==0) { cstate = 1; - for(std::list::iterator i = cookies.begin(); i != cookies.end(); i++) + for(std::list::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::iterator i = cookies.begin(); i != cookies.end(); i++) { + for(std::list::iterator i = lcookies.begin(); i != lcookies.end(); i++) { this->cookies[i->name] = *i; } }; //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()) { diff --git a/ext/yahttp/yahttp/reqresp.hpp b/ext/yahttp/yahttp/reqresp.hpp index 78882dd8e..5637e4442 100644 --- a/ext/yahttp/yahttp/reqresp.hpp +++ b/ext/yahttp/yahttp/reqresp.hpp @@ -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; }; //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"; }; //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(); diff --git a/ext/yahttp/yahttp/router.cpp b/ext/yahttp/yahttp/router.cpp index 3678000ea..a92be62b6 100644 --- a/ext/yahttp/yahttp/router.cpp +++ b/ext/yahttp/yahttp/router.cpp @@ -27,7 +27,6 @@ namespace YaHTTP { bool Router::route(Request *req, THandlerFunction& handler) { std::map params; int pos1,pos2; - std::string pname; bool matched = false; std::string rname;