Skip to content

Commit b7b229e

Browse files
committed
Use C locale for cookie Expires date formatting
1 parent 2dfeee8 commit b7b229e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

include/crow/middlewares/cookie_parser.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,16 @@ namespace crow
6767
dumpString(ss, httponly_, "HttpOnly");
6868
if (expires_at_)
6969
{
70-
ss << DIVIDER << "Expires="
71-
<< std::put_time(expires_at_.get(), HTTP_DATE_FORMAT);
70+
std::string old_locale_cstr = std::setlocale(LC_TIME, nullptr);
71+
std::setlocale(LC_TIME, "C");
72+
73+
char buf[100];
74+
if (std::strftime(buf, sizeof(buf), HTTP_DATE_FORMAT, expires_at_.get()))
75+
{
76+
ss << DIVIDER << "Expires=" << buf;
77+
}
78+
79+
std::setlocale(LC_TIME, old_locale_cstr.c_str());
7280
}
7381
if (max_age_)
7482
{

0 commit comments

Comments
 (0)