2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Make HttpHeader::getFirst(...) return const reference.
	* src/HttpHeader.cc
	* src/HttpHeader.h
pull/1/head
Tatsuhiro Tsujikawa 2008-05-18 10:33:06 +00:00
parent a0f8685de3
commit e1c1c010b8
3 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Make HttpHeader::getFirst(...) return const reference.
* src/HttpHeader.cc
* src/HttpHeader.h
2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use Option::getAsBool(...) instead of Option::get(...) and compare Use Option::getAsBool(...) instead of Option::get(...) and compare

View File

@ -83,7 +83,7 @@ bool HttpHeader::defined(const std::string& name) const {
return table.count(Util::toLower(name)) >= 1; return table.count(Util::toLower(name)) >= 1;
} }
std::string HttpHeader::getFirst(const std::string& name) const { const std::string& HttpHeader::getFirst(const std::string& name) const {
std::multimap<std::string, std::string>::const_iterator itr = table.find(Util::toLower(name)); std::multimap<std::string, std::string>::const_iterator itr = table.find(Util::toLower(name));
if(itr == table.end()) { if(itr == table.end()) {
return A2STR::NIL; return A2STR::NIL;
@ -107,7 +107,7 @@ unsigned int HttpHeader::getFirstAsUInt(const std::string& name) const {
} }
uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const { uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const {
std::string value = getFirst(name); const std::string& value = getFirst(name);
if(value.empty()) { if(value.empty()) {
return 0; return 0;
} else { } else {
@ -117,9 +117,9 @@ uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const {
RangeHandle HttpHeader::getRange() const RangeHandle HttpHeader::getRange() const
{ {
std::string rangeStr = getFirst(CONTENT_RANGE); const std::string& rangeStr = getFirst(CONTENT_RANGE);
if(rangeStr.empty()) { if(rangeStr.empty()) {
std::string contentLengthStr = getFirst(CONTENT_LENGTH); const std::string& contentLengthStr = getFirst(CONTENT_LENGTH);
if(contentLengthStr.empty()) { if(contentLengthStr.empty()) {
return SharedHandle<Range>(new Range()); return SharedHandle<Range>(new Range());
} else { } else {

View File

@ -62,7 +62,7 @@ public:
void put(const std::string& name, const std::string& value); void put(const std::string& name, const std::string& value);
bool defined(const std::string& name) const; bool defined(const std::string& name) const;
std::string getFirst(const std::string& name) const; const std::string& getFirst(const std::string& name) const;
std::deque<std::string> get(const std::string& name) const; std::deque<std::string> get(const std::string& name) const;
unsigned int getFirstAsUInt(const std::string& name) const; unsigned int getFirstAsUInt(const std::string& name) const;
uint64_t getFirstAsULLInt(const std::string& name) const; uint64_t getFirstAsULLInt(const std::string& name) const;