From e34d0e7ffa602d611ec6ec14cf9aa381da41c24e Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 30 Sep 2012 17:30:35 +0900 Subject: Dont' return SharedHandle from HttpHeader::getRange() --- src/HttpHeader.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/HttpHeader.cc') diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index a349a7a3..ae622b27 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -85,13 +85,13 @@ HttpHeader::equalRange(int hdKey) const return table_.equal_range(hdKey); } -SharedHandle HttpHeader::getRange() const +Range HttpHeader::getRange() const { const std::string& rangeStr = find(CONTENT_RANGE); if(rangeStr.empty()) { const std::string& clenStr = find(CONTENT_LENGTH); if(clenStr.empty()) { - return SharedHandle(new Range()); + return Range(); } else { int64_t contentLength; if(!util::parseLLIntNoThrow(contentLength, clenStr) || @@ -101,10 +101,9 @@ SharedHandle HttpHeader::getRange() const throw DOWNLOAD_FAILURE_EXCEPTION (fmt(EX_TOO_LARGE_FILE, contentLength)); } else if(contentLength == 0) { - return SharedHandle(new Range()); + return Range(); } else { - return SharedHandle - (new Range(0, contentLength-1, contentLength)); + return Range(0, contentLength - 1, contentLength); } } } @@ -130,11 +129,11 @@ SharedHandle HttpHeader::getRange() const // If byte-range-resp-spec or instance-length is "*", we returns // empty Range. The former is usually sent with 416 (Request range // not satisfiable) status. - return SharedHandle(new Range()); + return Range(); } std::string::const_iterator minus = std::find(byteRangeSpec, slash, '-'); if(minus == slash) { - return SharedHandle(new Range()); + return Range(); } int64_t startByte, endByte, entityLength; if(!util::parseLLIntNoThrow(startByte, std::string(byteRangeSpec, minus)) || @@ -153,7 +152,7 @@ SharedHandle HttpHeader::getRange() const if(entityLength > std::numeric_limits::max()) { throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, entityLength)); } - return SharedHandle(new Range(startByte, endByte, entityLength)); + return Range(startByte, endByte, entityLength); } void HttpHeader::setVersion(const std::string& version) -- cgit