Forráskód Böngészése

Use util::strifind instead of std::toLower and std::string::find.

Tatsuhiro Tsujikawa 14 éve
szülő
commit
f0f1cfab5c
2 módosított fájl, 12 hozzáadás és 7 törlés
  1. 2 3
      src/HttpRequest.cc
  2. 10 4
      src/HttpServer.cc

+ 2 - 3
src/HttpRequest.cc

@@ -445,10 +445,9 @@ bool HttpRequest::conditionalRequest() const
   static const char A2_IF_NONE_MATCH[] = "if-none-match";
   for(std::vector<std::string>::const_iterator i = headers_.begin(),
         eoi = headers_.end(); i != eoi; ++i) {
-    std::string hd = util::toLower(*i);
-    if(util::startsWith(hd.begin(), hd.end(),
+    if(util::istartsWith((*i).begin(), (*i).end(),
                         A2_IF_MOD_SINCE, vend(A2_IF_MOD_SINCE)-1) ||
-       util::startsWith(hd.begin(), hd.end(),
+       util::istartsWith((*i).begin(), (*i).end(),
                         A2_IF_NONE_MATCH, vend(A2_IF_NONE_MATCH)-1)) {
       return true;
     }

+ 10 - 4
src/HttpServer.cc

@@ -93,12 +93,18 @@ SharedHandle<HttpHeader> HttpServer::receiveRequest()
       lastRequestHeader_->findAsUInt(HttpHeader::CONTENT_LENGTH);
     headerProcessor_->clear();
 
-    std::string connection =
-      util::toLower(lastRequestHeader_->find(HttpHeader::CONNECTION));
+    const std::string& connection =
+      lastRequestHeader_->find(HttpHeader::CONNECTION);
     acceptsPersistentConnection_ =
-      connection.find(HttpHeader::CLOSE) == std::string::npos &&
+      util::strifind(connection.begin(),
+                     connection.end(),
+                     HttpHeader::CLOSE.begin(),
+                     HttpHeader::CLOSE.end()) == connection.end() &&
       (lastRequestHeader_->getVersion() == HttpHeader::HTTP_1_1 ||
-       connection.find("keep-alive") != std::string::npos);
+       util::strifind(connection.begin(),
+                      connection.end(),
+                      HttpHeader::KEEP_ALIVE.begin(),
+                      HttpHeader::KEEP_ALIVE.end()) != connection.end());
 
     std::vector<Scip> acceptEncodings;
     const std::string& acceptEnc =