Hi. I'm not currently able to roll any new releases, but here is a quick
patch that allows on to send Expires: headers. Usage is as follows.
Suppose you want to send an expires: header that points to one day in the
future. You do this by

  Control {
    ExpireInterval 86400
  }

Note that expireinterval only adds an "expires" header; if you want to
send a cache-control or something as well you need to do this the
old-fashioned way:

  Control {
    ExpireInterval 86400
    ExtraHeaders { "Cache-Control: max-age=86400" }
  }

Let me know if this has any effect.

Cheers
Michiel
Index: config.c
===================================================================
RCS file: /usr/home/boland/cvs/repository/mathopd/src/config.c,v
retrieving revision 1.181
diff -u -r1.181 config.c
--- config.c    31 Mar 2004 12:38:13 -0000      1.181
+++ config.c    8 Apr 2004 20:33:21 -0000
@@ -103,6 +103,7 @@
 static const char c_error_401_file[] =         "Error401File";
 static const char c_error_404_file[] =         "Error404File";
 static const char c_exact_match[] =            "ExactMatch";
+static const char c_expire_interval[] =                "ExpireInterval";
 static const char c_export[] =                 "Export";
 static const char c_external[] =               "External";
 static const char c_extra_headers[] =          "ExtraHeaders";
@@ -539,6 +540,7 @@
                a->extra_headers = b->extra_headers;
                a->path_info_ok = b->path_info_ok;
                a->auto_index_command = b->auto_index_command;
+               a->expire_interval = b->expire_interval;
        } else {
                a->index_names = 0;
                a->mimes = 0;
@@ -559,6 +561,7 @@
                a->extra_headers = 0;
                a->path_info_ok = 1;
                a->auto_index_command = 0;
+               a->expire_interval = 0;
        }
        a->next = *as;
        *as = a;
@@ -634,6 +637,8 @@
                        t = config_flag(p, &a->path_info_ok);
                else if (!strcasecmp(p->tokbuf, c_auto_index_command))
                        t = config_string(p, &a->auto_index_command);
+               else if (!strcasecmp(p->tokbuf, c_expire_interval))
+                       t = config_int(p, &a->expire_interval);
                else
                        t = e_keyword;
                if (t)
Index: mathopd.h
===================================================================
RCS file: /usr/home/boland/cvs/repository/mathopd/src/mathopd.h,v
retrieving revision 1.242
diff -u -r1.242 mathopd.h
--- mathopd.h   31 Mar 2004 12:38:13 -0000      1.242
+++ mathopd.h   8 Apr 2004 20:37:31 -0000
@@ -166,6 +166,7 @@
        struct simple_list *extra_headers;
        int path_info_ok;
        char *auto_index_command;
+       unsigned long expire_interval;
 };
 
 struct virtual {
Index: request.c
===================================================================
RCS file: /usr/home/boland/cvs/repository/mathopd/src/request.c,v
retrieving revision 1.302
diff -u -r1.302 request.c
--- request.c   31 Mar 2004 11:02:38 -0000      1.302
+++ request.c   8 Apr 2004 20:36:02 -0000
@@ -1372,6 +1372,7 @@
        struct simple_list *h;
        const char *status_line;
        char *cl_start, *cl_end;
+       time_t et;
 
        if (r->forked)
                return 0;
@@ -1441,10 +1442,16 @@
        } else if (r->protocol_minor)
                if (pool_print(p, "Connection: close\r\n") == -1)
                        return -1;
-       if (r->c && r->status == 200)
+       if (r->c && r->status == 200) {
+               if (r->c->expire_interval) {
+                       et = current_time + r->c->expire_interval;
+                       if (pool_print(p, "Expires: %s\r\n", rfctime(et, gbuf)) == -1)
+                               return -1;
+               }
                for (h = r->c->extra_headers; h; h = h->next)
                        if (pool_print(p, "%s\r\n", h->name) == -1)
                                return -1;
+       }
        if (pool_print(p, "\r\n") == -1)
                return -1;
        p->middle = p->end;

Reply via email to