mirror of
https://github.com/aria2/aria2.git
synced 2026-04-02 02:38:50 +00:00
Support HTTP date ending "+0000" as well as "GMT".
This commit is contained in:
@@ -203,6 +203,11 @@ Time Time::parseRFC1123(const std::string& datetime)
|
||||
return parse(datetime, "%a, %d %b %Y %H:%M:%S GMT");
|
||||
}
|
||||
|
||||
Time Time::parseRFC1123Alt(const std::string& datetime)
|
||||
{
|
||||
return parse(datetime, "%a, %d %b %Y %H:%M:%S +0000");
|
||||
}
|
||||
|
||||
Time Time::parseRFC850(const std::string& datetime)
|
||||
{
|
||||
return parse(datetime, "%a, %d-%b-%y %H:%M:%S GMT");
|
||||
@@ -222,6 +227,7 @@ Time Time::parseHTTPDate(const std::string& datetime)
|
||||
{
|
||||
Time (*funcs[])(const std::string&) = {
|
||||
&parseRFC1123,
|
||||
&parseRFC1123Alt,
|
||||
&parseRFC850,
|
||||
&parseAsctime,
|
||||
&parseRFC850Ext,
|
||||
|
||||
@@ -120,6 +120,10 @@ public:
|
||||
// Currently timezone is assumed to GMT.
|
||||
static Time parseRFC1123(const std::string& datetime);
|
||||
|
||||
// Like parseRFC1123, but only accepts trailing "+0000" instead of
|
||||
// last 3 letters "GMT".
|
||||
static Time parseRFC1123Alt(const std::string& datetime);
|
||||
|
||||
// Currently timezone is assumed to GMT.
|
||||
static Time parseRFC850(const std::string& datetime);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
void tearDown() {}
|
||||
|
||||
void testParseRFC1123();
|
||||
void testParseRFC1123Alt();
|
||||
void testParseRFC850();
|
||||
void testParseRFC850Ext();
|
||||
void testParseAsctime();
|
||||
@@ -45,6 +46,12 @@ void TimeTest::testParseRFC1123()
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793, t1.getTime());
|
||||
}
|
||||
|
||||
void TimeTest::testParseRFC1123Alt()
|
||||
{
|
||||
Time t1 = Time::parseRFC1123Alt("Sat, 06 Sep 2008 15:26:33 +0000");
|
||||
CPPUNIT_ASSERT_EQUAL((time_t)1220714793, t1.getTime());
|
||||
}
|
||||
|
||||
void TimeTest::testParseRFC850()
|
||||
{
|
||||
Time t1 = Time::parseRFC850("Saturday, 06-Sep-08 15:26:33 GMT");
|
||||
|
||||
Reference in New Issue
Block a user