src: Use StringRef in parse_http_date

This commit is contained in:
Tatsuhiro Tsujikawa 2016-03-12 17:31:48 +09:00
parent 863a944179
commit c897d5b294
4 changed files with 5 additions and 5 deletions

View File

@ -1235,7 +1235,7 @@ void prepare_response(Stream *stream, Http2Handler *hd,
bool last_mod_found = false;
if (ims) {
last_mod_found = true;
last_mod = util::parse_http_date(ims->value);
last_mod = util::parse_http_date(StringRef{ims->value});
}
auto query_pos = reqpath.find("?");
std::string url;

View File

@ -339,7 +339,7 @@ std::string iso8601_date(int64_t ms) {
return res;
}
time_t parse_http_date(const std::string &s) {
time_t parse_http_date(const StringRef &s) {
tm tm{};
char *r = strptime(s.c_str(), "%a, %d %b %Y %H:%M:%S GMT", &tm);
if (r == 0) {

View File

@ -149,7 +149,7 @@ std::string common_log_date(time_t t);
// 2014-11-15T12:58:24.741Z)
std::string iso8601_date(int64_t ms);
time_t parse_http_date(const std::string &s);
time_t parse_http_date(const StringRef &s);
char upcase(char c);

View File

@ -392,8 +392,8 @@ void test_util_ends_with(void) {
}
void test_util_parse_http_date(void) {
CU_ASSERT(1001939696 ==
util::parse_http_date("Mon, 1 Oct 2001 12:34:56 GMT"));
CU_ASSERT(1001939696 == util::parse_http_date(StringRef::from_lit(
"Mon, 1 Oct 2001 12:34:56 GMT")));
}
void test_util_localtime_date(void) {