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

pull/2/head
Tatsuhiro Tsujikawa 2011-11-12 01:13:55 +09:00
parent 2f4393d17c
commit f0f1cfab5c
2 changed files with 12 additions and 7 deletions

View File

@ -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;
}

View File

@ -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 =