Browse Source

Fix max-age value in mod_expire for 'modification' (fixes #1978)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2503 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.23
Stefan Bühler 13 years ago
parent
commit
69987ea95f
  1. 1
      NEWS
  2. 18
      src/mod_expire.c

1
NEWS

@ -39,6 +39,7 @@ NEWS
* Fix x-sendfile 2gb limiting (fixes #1970)
* Fix mod_cgi environment keys mangling (fixes #1969)
* Fix workaround for incorrect path info/scriptname if scgi prefix is "/" (fixes #729)
* Fix max-age value in mod_expire for 'modification' (fixes #1978)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)

18
src/mod_expire.c

@ -75,10 +75,10 @@ FREE_FUNC(mod_expire_free) {
return HANDLER_GO_ON;
}
static int mod_expire_get_offset(server *srv, plugin_data *p, buffer *expire, int *offset) {
static int mod_expire_get_offset(server *srv, plugin_data *p, buffer *expire, time_t *offset) {
char *ts;
int type = -1;
int retts = 0;
time_t retts = 0;
UNUSED(p);
@ -302,8 +302,7 @@ URIHANDLER_FUNC(mod_expire_path_handler) {
if (ds->key->used == 0) continue;
if (0 == strncmp(con->uri.path->ptr, ds->key->ptr, ct_len)) {
int ts;
time_t t;
time_t ts, expires;
size_t len;
stat_cache_entry *sce = NULL;
@ -312,25 +311,26 @@ URIHANDLER_FUNC(mod_expire_path_handler) {
switch(mod_expire_get_offset(srv, p, ds->value, &ts)) {
case 0:
/* access */
t = (ts + srv->cur_ts);
expires = (ts + srv->cur_ts);
break;
case 1:
/* modification */
t = (ts + sce->st.st_mtime);
expires = (ts + sce->st.st_mtime);
break;
default:
/* -1 is handled at parse-time */
break;
}
/* expires should be at least srv->cur_ts */
if (expires < srv->cur_ts) expires = srv->cur_ts;
if (0 == (len = strftime(p->expire_tstmp->ptr, p->expire_tstmp->size - 1,
"%a, %d %b %Y %H:%M:%S GMT", gmtime(&(t))))) {
"%a, %d %b %Y %H:%M:%S GMT", gmtime(&(expires))))) {
/* could not set expire header, out of mem */
return HANDLER_GO_ON;
}
p->expire_tstmp->used = len + 1;
@ -340,7 +340,7 @@ URIHANDLER_FUNC(mod_expire_path_handler) {
/* HTTP/1.1 */
buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age="));
buffer_append_long(p->expire_tstmp, ts);
buffer_append_long(p->expire_tstmp, expires - srv->cur_ts); /* as expires >= srv->cur_ts the difference is >= 0 */
response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));

Loading…
Cancel
Save