storage/curl: make timestamp parsing more robust
According to the latest WebDAV specification (RFC4918), timestamp string in the getlastmodified property is formatted as rfc1123-date, such as "Sun, 06 Nov 1994 08:49:37 GMT". However, to process responses from servers in the older style format specified in RFC2518, timestamps in the HTTP-date format had better be accepted. As described in the libcurl api documentation, curl_getdate() can handle timestamp strings in HTTP-date formats, including rfc1123-date. https://www.rfc-editor.org/rfc/rfc4918#section-15.7 https://www.rfc-editor.org/rfc/rfc2518.html#section-13.7 https://curl.se/libcurl/c/curl_getdate.html
This commit is contained in:
parent
df71b07e9d
commit
99e65c58ce
@ -194,12 +194,7 @@ ParseStatus(const char *s, size_t length) noexcept
|
|||||||
static std::chrono::system_clock::time_point
|
static std::chrono::system_clock::time_point
|
||||||
ParseTimeStamp(const char *s) noexcept
|
ParseTimeStamp(const char *s) noexcept
|
||||||
{
|
{
|
||||||
try {
|
return std::chrono::system_clock::from_time_t(curl_getdate(s, nullptr));
|
||||||
// TODO: make this more robust
|
|
||||||
return ParseTimePoint(s, "%a, %d %b %Y %T");
|
|
||||||
} catch (...) {
|
|
||||||
return std::chrono::system_clock::time_point::min();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::pure]]
|
[[gnu::pure]]
|
||||||
|
Loading…
Reference in New Issue
Block a user