mirror of https://github.com/aria2/aria2
2010-10-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Return empty range if byte-range-resp-spec or instance-length is "*" in Content-Range header to prevent aria2 from emitting error failing to convert "*" to a integer. * src/HttpHeader.cc * test/HttpHeaderTest.ccpull/1/head
parent
2b458da480
commit
35cc4ed1e7
|
@ -1,3 +1,11 @@
|
||||||
|
2010-10-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Return empty range if byte-range-resp-spec or instance-length is
|
||||||
|
"*" in Content-Range header to prevent aria2 from emitting error
|
||||||
|
failing to convert "*" to a integer.
|
||||||
|
* src/HttpHeader.cc
|
||||||
|
* test/HttpHeaderTest.cc
|
||||||
|
|
||||||
2010-10-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-10-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Made #include guard consistent for c++ header files.
|
Made #include guard consistent for c++ header files.
|
||||||
|
|
|
@ -180,6 +180,14 @@ RangeHandle HttpHeader::getRange() const
|
||||||
std::pair<std::string, std::string> byteRangeSpecPair;
|
std::pair<std::string, std::string> byteRangeSpecPair;
|
||||||
util::divide(byteRangeSpecPair, byteRangeSpec, '/');
|
util::divide(byteRangeSpecPair, byteRangeSpec, '/');
|
||||||
|
|
||||||
|
if(util::strip(byteRangeSpecPair.first) == "*" ||
|
||||||
|
util::strip(byteRangeSpecPair.second) == "*") {
|
||||||
|
// 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<Range>(new Range());
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<std::string, std::string> byteRangeRespSpecPair;
|
std::pair<std::string, std::string> byteRangeRespSpecPair;
|
||||||
util::divide(byteRangeRespSpecPair, byteRangeSpecPair.first, '-');
|
util::divide(byteRangeRespSpecPair, byteRangeSpecPair.first, '-');
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,26 @@ void HttpHeaderTest::testGetRange()
|
||||||
CPPUNIT_ASSERT_EQUAL((off_t)9223372036854775801LL, range->getEndByte());
|
CPPUNIT_ASSERT_EQUAL((off_t)9223372036854775801LL, range->getEndByte());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)9223372036854775807ULL, range->getEntityLength());
|
CPPUNIT_ASSERT_EQUAL((uint64_t)9223372036854775807ULL, range->getEntityLength());
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
HttpHeader httpHeader;
|
||||||
|
httpHeader.put("Content-Range", "bytes */1024");
|
||||||
|
|
||||||
|
SharedHandle<Range> range = httpHeader.getRange();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL((off_t)0, range->getStartByte());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((off_t)0, range->getEndByte());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((uint64_t)0, range->getEntityLength());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
HttpHeader httpHeader;
|
||||||
|
httpHeader.put("Content-Range", "bytes 0-9/*");
|
||||||
|
|
||||||
|
SharedHandle<Range> range = httpHeader.getRange();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL((off_t)0, range->getStartByte());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((off_t)0, range->getEndByte());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((uint64_t)0, range->getEntityLength());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpHeaderTest::testGet()
|
void HttpHeaderTest::testGet()
|
||||||
|
|
Loading…
Reference in New Issue