Closed p0nce closed 4 months ago
That should be set as any other header. But it seems there's no easy/fast way to format a date in D as required by RFC 7231 Sun, 06 Nov 1994 08:49:37 GMT
. Is there?
In another part of serverino I format it in this way:
string[] mm = ["", "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
string[] dd = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
SysTime gmt = c._expire.toUTC();
string data = format("%s, %s %s %s %s:%s:%s GMT",
dd[gmt.dayOfWeek], gmt.day, mm[gmt.month], gmt.year,
gmt.hour, gmt.minute, gmt.second
);
Should I add a toXXXString(SysTime d)
so you can write (Clock.currTime() + 1.days).toXXXString()
?
to7231String/Date
toHTTPString/Date
?
In an ideal world I would just say:
output.expiresHeader(Duration duration)
and it would do it relatively. (with a nice identifier of course, not especially expiresHeader)
Yes I know but I don't like the idea to wrap every single header. I have to keep the whole thing light.
I know it's an exception, but then exceptions became a (bad) pratice...
(anyway cache is not always relative, f.e. "sorry, the website will be online from Jan 1st")
Ah so basically a case of "I haven't found the snippet of code to do that", it doesn't need to be a code change. I felt the same for MIME type but ultimately yours to decide.
I don't follow you. What do you mean?
Ok I have an idea. RFC7231 says that every header must use that format for dates. So I will overload the addHeader()
function adding:
addHeader(string, SysTime)
and
addHeader(string, Duration)
So you can write:
output.addHeader("expire", 3.days);
It should be a good fix, isn't it?
Hey @p0nce are you still testing serverino? Just to know if wait for more fixes (hope not) or make a new release...
I'm using it successfully for this website, I'm not in need of anything in particular :) Very nice lib
🤩
Nice! I think you'd like the Severino/Parserino integration for this kind of websites.
What would be the equivalent of:
cgi.setResponseExpiresRelative(24 * 60 * 60);
This sets a Expires header 24h later in order to use HTTP cache.