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

Make HttpHeader::getFirst(...) return const reference.
	* src/HttpHeader.cc
	* src/HttpHeader.h
This commit is contained in:
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>
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;
}
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));
if(itr == table.end()) {
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 {
std::string value = getFirst(name);
const std::string& value = getFirst(name);
if(value.empty()) {
return 0;
} else {
@ -117,9 +117,9 @@ uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const {
RangeHandle HttpHeader::getRange() const
{
std::string rangeStr = getFirst(CONTENT_RANGE);
const std::string& rangeStr = getFirst(CONTENT_RANGE);
if(rangeStr.empty()) {
std::string contentLengthStr = getFirst(CONTENT_LENGTH);
const std::string& contentLengthStr = getFirst(CONTENT_LENGTH);
if(contentLengthStr.empty()) {
return SharedHandle<Range>(new Range());
} else {

View File

@ -62,7 +62,7 @@ public:
void put(const std::string& name, const std::string& value);
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;
unsigned int getFirstAsUInt(const std::string& name) const;
uint64_t getFirstAsULLInt(const std::string& name) const;