Only in dillo-cache-control: ]
Only in dillo-cache-control: autom4te.cache
Only in dillo-cache-control: config.guess
Only in dillo-cache-control: config.h
Only in dillo-cache-control: config.log
Only in dillo-cache-control: config.status
Only in dillo-cache-control: config.sub
Only in dillo-cache-control: depcomp
Only in dillo-cache-control/dpi: .deps
Only in dillo-cache-control/dpi: bm_srv12
Only in dillo-cache-control/dpi: bm_srv12.o
Only in dillo-cache-control: install-sh
Only in dillo-cache-control: missing
Only in dillo-cache-control: mkinstalldirs
Only in dillo-cache-control/src: .deps
Only in dillo-cache-control/src/IO: .deps
Only in dillo-cache-control/src/IO: IO.o
Only in dillo-cache-control/src/IO: Url.o
Only in dillo-cache-control/src/IO: about.o
Only in dillo-cache-control/src/IO: dpi.o
Only in dillo-cache-control/src/IO: file.o
Only in dillo-cache-control/src/IO: http.o
Only in dillo-cache-control/src/IO: libDio.a
Only in dillo-cache-control/src/IO: mime.o
Only in dillo-cache-control/src/IO: proto.o
Only in dillo-cache-control/src: bitvec.o
Only in dillo-cache-control/src: bookmark.o
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/cache.c dillo-cache-control/src/cache.c
--- cvs/dillo/src/cache.c	2003-04-23 01:58:19.000000000 +0300
+++ dillo-cache-control/src/cache.c	2003-05-01 21:59:14.000000000 +0300
@@ -17,6 +17,7 @@
 #include <sys/types.h>
 
 #include <sys/stat.h>
+#include <time.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
@@ -30,6 +31,7 @@
 #include "interface.h"
 #include "nav.h"
 #include "cookies.h"
+#include "prefs.h"
 #include "misc.h"
 
 #define NULLKey 0
@@ -54,6 +56,7 @@ typedef struct {
    IOData_t *io;             /* Pointer to IO data */
    ChainLink *CCCQuery;      /* CCC link for querying branch */
    ChainLink *CCCAnswer;     /* CCC link for answering branch */
+   time_t Expires;           /* when this data should be reloaded */
 } CacheData_t;
 
 
@@ -204,10 +207,11 @@ static void Cache_entry_init(CacheData_t
    NewEntry->ValidSize = 0;
    NewEntry->TotalSize = 0;
    NewEntry->BuffSize = 4096;
-   NewEntry->Flags = 0;
+   NewEntry->Flags = URL_FLAGS_(Url) & URL_Post ? CA_Expires : 0;
    NewEntry->io = NULL;
    NewEntry->CCCQuery = a_Chain_new();
    NewEntry->CCCAnswer = NULL;
+   NewEntry->Expires = 0;
 }
 
 /*
@@ -344,6 +348,8 @@ static gint Cache_prepare_reload(DilloUr
    return 0;
 }
 
+#define URL_ImageOnOtherHost (URL_IsImage | URL_OnOtherHost)
+
 /*
  * Try finding the url in the cache. If it hits, send the cache contents
  * from there. If it misses, set up a new connection.
@@ -357,6 +363,15 @@ static gint Cache_open_url(DilloWeb *Web
    DilloUrl *Url = Web->url;
    CacheData_t *entry = Cache_entry_search(Url);
 
+   if ( entry && (entry->Flags & CA_Expires) &&
+        (!entry->Expires || entry->Expires <= time(NULL)) &&
+        !(URL_FLAGS(Url) & URL_MustCache) &&
+        ((URL_FLAGS(Url) & URL_ImageOnOtherHost) != URL_ImageOnOtherHost) &&
+        !g_slist_find_custom(ClientQueue, Url, Cache_client_url_cmp)) {
+      Cache_entry_remove(entry, Url);
+      entry = NULL;
+      DEBUG_HTTP_MSG("Reloading >%s< because it shouldn't be cached\n", URL_STR(Url));
+   }
    if ( !entry ) {
       /* URL not cached: create an entry, send our client to the queue,
        * and open a new connection */
@@ -534,6 +549,36 @@ GList *Cache_parse_multiple_fields(const
    return fields;
 }
 
+/* This should really be in some header file
+   (and the function shouldn't be in cookies.c probably) */
+time_t Cookies_create_timestamp(const char *expires);
+
+static void force_min_expire(CacheData_t *entry, int min, guint stdExp) {
+   time_t t;
+
+   if (!(entry->Flags & CA_Expires) || (URL_FLAGS_(entry->Url) & URL_Post))
+      return;
+   if (min < 0) {
+      entry->Flags &= ~CA_Expires;
+      entry->Expires = 0;
+      return;
+   }
+   t = time(0);
+   if (entry->Expires && t > entry->Expires + 1000) {
+      if (!stdExp)
+         entry->Flags &= ~CA_Expires;
+      entry->Expires = 0;
+      DEBUG_HTTP_MSG("Bad clocks, ignore expire on >%s<\n", URL_STR(entry->Url));
+      return;
+   }
+   if (min && (t += min) > entry->Expires) {
+      DEBUG_HTTP_MSG("Forcing min expire %d on >%s< instead %ld\n", min,
+                     URL_STR(entry->Url), entry->Expires ?
+                     entry->Expires - (t - min) : 0);
+      entry->Expires = t;
+   }
+}
+
 /*
  * Scan, allocate, and set things according to header info.
  * (This function needs the whole header to work)
@@ -541,7 +586,8 @@ GList *Cache_parse_multiple_fields(const
 static void Cache_parse_header(CacheData_t *entry, IOData_t *io, gint HdrLen)
 {
    gchar *header = entry->Header->str;
-   gchar *Length, *Type, *location_str;
+   gchar *Length, *Type, *CacheControl, *Date, *CC_ptr, *location_str;
+   guint expFlag;
 #ifndef DISABLE_COOKIES
    GList *Cookies;
 #endif
@@ -552,6 +598,9 @@ static void Cache_parse_header(CacheData
       if ( header[11] == '1' )
          /* 301 Moved Permanently */
          entry->Flags |= CA_ForceRedirect;
+      if ( header[11] == '2' || header[11] == '3' || header[11] == '7' )
+         entry->Flags |= CA_Expires; /* 302 Found or 307 Moved Temporarely */
+/* TODO: should be here a_Url_free(entry->Location) ? */
       location_str = Cache_parse_field(header, "Location");
       entry->Location = a_Url_new(location_str, URL_STR_(entry->Url), 0, 0);
       g_free(location_str);
@@ -559,7 +608,8 @@ static void Cache_parse_header(CacheData
    } else if ( strncmp(header + 9, "404", 3) == 0 ) {
       entry->Flags |= CA_NotFound;
    }
-
+   expFlag = entry->Flags & CA_Expires;
+   
    entry->ValidSize = io->Status - HdrLen;
    if ( (Length = Cache_parse_field(header, "Content-Length")) != NULL ) {
       entry->Flags |= CA_GotLength;
@@ -569,6 +619,41 @@ static void Cache_parse_header(CacheData
          entry->TotalSize = 0;
    }
 
+   if ( (CacheControl = Cache_parse_field(header, "Expires")) != NULL ) {
+      entry->Flags |= CA_Expires;
+      entry->Expires = Cookies_create_timestamp(CacheControl);
+      g_free(CacheControl);
+   }
+
+   if ( (CacheControl = Cache_parse_field(header, "Cache-Control")) != NULL ) {
+      CC_ptr = CacheControl;
+      do {
+         while (*CC_ptr == ' ')
+            ++CC_ptr;
+         if ( !g_strncasecmp(CacheControl, "no-cache", 8) ) {
+            entry->Flags |= CA_Expires;
+            entry->Expires = 0;
+            break;
+         } else if ( !g_strncasecmp(CacheControl, "max-age=", 8) ) {
+            char *e;
+            long n;
+
+            if ( !(Date = Cache_parse_field(header, "Date")) ) {
+               DEBUG_HTTP_MSG("'Cache-Control: max-age=' without 'Date: ' header");
+               break;
+            }
+           n = strtoul(CacheControl + 8, &e, 10);
+           if (e > CacheControl + 8 && n >= 0) {
+               entry->Flags |= CA_Expires;
+               entry->Expires = n + Cookies_create_timestamp(Date);
+            }
+            g_free(Date);
+            break;
+         }
+      } while ( (CC_ptr = strchr(CC_ptr, ',')) && *++CC_ptr );
+      g_free(CacheControl);
+   }
+
 #ifndef DISABLE_COOKIES
    /* BUG: If a server feels like mixing Set-Cookie2 and Set-Cookie
     * responses which aren't identical, then we have a problem. I don't
@@ -603,6 +688,19 @@ static void Cache_parse_header(CacheData
                         entry->Data, entry->ValidSize));
    }
    entry->Type = Type;
+
+   if (URL_FLAGS(entry->Url) & URL_IsImage || !strncmp(Type, "image/", 5)) {
+      force_min_expire(entry, prefs.min_image_expire_time, expFlag);
+   } else if (!(entry->Flags & CA_Expires) &&
+              (entry->Location ? entry->Location->query : entry->Url->query) &&
+              prefs.query_expire_time >= 0 && !strncmp(Type, "text/", 5)) {
+      entry->Flags |= CA_Expires;
+      entry->Expires = time(NULL) + prefs.query_expire_time;
+      DEBUG_MSG(5, "Forcing default expire to query url >%s<\n",
+         URL_STR(entry->Url));
+   } else {
+      force_min_expire(entry, prefs.min_page_expire_time, expFlag);
+   }
 }
 
 /*
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/cache.h dillo-cache-control/src/cache.h
--- cvs/dillo/src/cache.h	2002-02-20 18:02:21.000000000 +0200
+++ dillo-cache-control/src/cache.h	2003-05-01 19:17:58.000000000 +0300
@@ -25,6 +25,7 @@
 #define CA_Stopped      (128)  /* True if the entry has been stopped */
 #define CA_MsgErased    (256)  /* Used to erase the bw's status bar */
 #define CA_RedirectLoop (512)  /* Redirect loop */
+#define CA_Expires     (1024)  /* Should be reloaded, when expired */
 
 /*
  * Callback type for cache clients
Only in dillo-cache-control/src: cache.o
Only in dillo-cache-control/src: capi.o
Only in dillo-cache-control/src: chain.o
Only in dillo-cache-control/src: colors.o
Only in dillo-cache-control/src: commands.o
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/cookies.c dillo-cache-control/src/cookies.c
--- cvs/dillo/src/cookies.c	2003-04-23 01:58:20.000000000 +0300
+++ dillo-cache-control/src/cookies.c	2003-05-01 19:17:58.000000000 +0300
@@ -352,7 +352,7 @@ static int Cookies_get_month(const char 
  * Accept: RFC-1123 | RFC-850 | ANSI asctime
  * (return 0 on malformed date string syntax)
  */
-static time_t Cookies_create_timestamp(const char *expires)
+time_t Cookies_create_timestamp(const char *expires)
 {
    time_t ret;
    int day, month, year, hour, minutes, seconds;
Only in dillo-cache-control/src: cookies.o
Only in dillo-cache-control/src: dicache.o
Only in dillo-cache-control/src: dillo
Only in dillo-cache-control/src: dillo.o
Only in dillo-cache-control/src: dns.o
Only in dillo-cache-control/src: dw.o
Only in dillo-cache-control/src: dw_aligned_page.o
Only in dillo-cache-control/src: dw_bullet.o
Only in dillo-cache-control/src: dw_button.o
Only in dillo-cache-control/src: dw_container.o
Only in dillo-cache-control/src: dw_embed_gtk.o
Only in dillo-cache-control/src: dw_ext_iterator.o
Only in dillo-cache-control/src: dw_gtk_scrolled_frame.o
Only in dillo-cache-control/src: dw_gtk_scrolled_window.o
Only in dillo-cache-control/src: dw_gtk_statuslabel.o
Only in dillo-cache-control/src: dw_gtk_viewport.o
Only in dillo-cache-control/src: dw_hruler.o
Only in dillo-cache-control/src: dw_image.o
Only in dillo-cache-control/src: dw_list_item.o
Only in dillo-cache-control/src: dw_marshal.o
Only in dillo-cache-control/src: dw_page.o
Only in dillo-cache-control/src: dw_style.o
Only in dillo-cache-control/src: dw_table.o
Only in dillo-cache-control/src: dw_table_cell.o
Only in dillo-cache-control/src: dw_tooltip.o
Only in dillo-cache-control/src: dw_widget.o
Only in dillo-cache-control/src: findtext.o
Only in dillo-cache-control/src: gif.o
Only in dillo-cache-control/src: history.o
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/html.c dillo-cache-control/src/html.c
--- cvs/dillo/src/html.c	2003-05-01 18:23:36.000000000 +0300
+++ dillo-cache-control/src/html.c	2003-05-01 19:17:58.000000000 +0300
@@ -1930,6 +1930,9 @@ static void Html_load_image(DilloHtml *h
    DilloWeb *Web;
    gint ClientKey;
    /* Fill a Web structure for the cache query */
+   if (URL_FLAGS(html->linkblock->base_url) && URL_MustCache)
+       URL_FLAGS(url) |= URL_MustCache; /* cache page, cache images */
+   URL_FLAGS(url) |= URL_IsImage;
    Web = a_Web_new(url);
    Web->bw = html->bw;
    Web->Image = Image;
Only in dillo-cache-control/src: html.o
Only in dillo-cache-control/src: image.o
Only in dillo-cache-control/src: interface.o
Only in dillo-cache-control/src: jpeg.o
Only in dillo-cache-control/src: klist.o
Only in dillo-cache-control/src: menu.o
Only in dillo-cache-control/src: misc.o
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/nav.c dillo-cache-control/src/nav.c
--- cvs/dillo/src/nav.c	2003-03-25 22:25:33.000000000 +0200
+++ dillo-cache-control/src/nav.c	2003-05-01 19:17:58.000000000 +0300
@@ -232,7 +232,7 @@ void a_Nav_expect_done(BrowserWindow *bw
    if (bw->nav_expecting) {
       url = bw->nav_expect_url;
       /* unset E2EReload before adding this url to history */
-      a_Url_set_flags(url, URL_FLAGS(url) & ~URL_E2EReload);
+      a_Url_set_flags(url, (URL_FLAGS(url) & ~URL_E2EReload) | URL_MustCache);
       idx = a_History_add_url(url);
       Nav_stack_add(bw, idx);
 
Only in dillo-cache-control/src: nav.o
Only in dillo-cache-control/src: plain.o
Only in dillo-cache-control/src: png.o
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/prefs.c dillo-cache-control/src/prefs.c
--- cvs/dillo/src/prefs.c	2003-04-10 02:09:06.000000000 +0300
+++ dillo-cache-control/src/prefs.c	2003-05-01 19:17:58.000000000 +0300
@@ -68,7 +68,10 @@ static const struct {
    { "vw_fontname", DRC_TOKEN_VW_FONT },
    { "fw_fontname", DRC_TOKEN_FW_FONT },
    { "generate_submit", DRC_TOKEN_GENERATE_SUBMIT },
-   { "enterpress_forces_submit", DRC_TOKEN_ENTERPRESS_FORCES_SUBMIT }
+   { "enterpress_forces_submit", DRC_TOKEN_ENTERPRESS_FORCES_SUBMIT },
+   { "query_expire_time", DRC_TOKEN_QUERY_EXPIRE_TIME },
+   { "min_page_expire", DRC_TOKEN_MIN_PAGE_EXPIRE_TIME },
+   { "min_image_expire", DRC_TOKEN_MIN_IMAGE_EXPIRE_TIME }
 };
 
 static const guint n_symbols = sizeof (symbols) / sizeof (symbols[0]);
@@ -233,7 +236,16 @@ static guint Prefs_parser(GScanner *scan
       prefs.enterpress_forces_submit =
          (strcmp(scanner->value.v_string, "YES") == 0);
       break;
-   default:
+   case DRC_TOKEN_QUERY_EXPIRE_TIME:
+      prefs.query_expire_time = strtol(scanner->value.v_string, NULL, 10);
+      break;
+   case DRC_TOKEN_MIN_PAGE_EXPIRE_TIME:
+      prefs.min_page_expire_time = strtol(scanner->value.v_string, NULL, 10);
+      break;
+    case DRC_TOKEN_MIN_IMAGE_EXPIRE_TIME:
+      prefs.min_image_expire_time = strtol(scanner->value.v_string, NULL, 10);
+      break;
+    default:
       break;   /* Not reached */
    }
    return G_TOKEN_NONE;
@@ -364,6 +376,9 @@ void a_Prefs_init(void)
    prefs.fw_fontname = g_strdup("courier");
    prefs.generate_submit = FALSE;
    prefs.enterpress_forces_submit = FALSE;
+   prefs.query_expire_time = -1;
+   prefs.min_page_expire_time = 60; // some sites need 0. 60; // 1 minute
+   prefs.min_image_expire_time = 1800; // 30 minutes
 
    /* this locale stuff is to avoid parsing problems with float numbers */
    old_locale = g_strdup (setlocale (LC_NUMERIC, NULL));
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/prefs.h dillo-cache-control/src/prefs.h
--- cvs/dillo/src/prefs.h	2003-02-17 19:41:58.000000000 +0200
+++ dillo-cache-control/src/prefs.h	2003-05-01 19:17:58.000000000 +0300
@@ -61,6 +61,9 @@ typedef enum {
    DRC_TOKEN_VW_FONT,
    DRC_TOKEN_GENERATE_SUBMIT,
    DRC_TOKEN_ENTERPRESS_FORCES_SUBMIT,
+   DRC_TOKEN_QUERY_EXPIRE_TIME,
+   DRC_TOKEN_MIN_PAGE_EXPIRE_TIME,
+   DRC_TOKEN_MIN_IMAGE_EXPIRE_TIME,
 
    DRC_TOKEN_LAST
 } Dillo_Rc_TokenType;
@@ -105,6 +108,9 @@ struct _DilloPrefs {
    gchar *fw_fontname;
    gboolean generate_submit;
    gboolean enterpress_forces_submit;
+   gint query_expire_time;
+   gint min_page_expire_time;
+   gint min_image_expire_time;
 };
 
 /* Global Data */
Only in dillo-cache-control/src: prefs.o
Only in dillo-cache-control/src: progressbar.o
Only in dillo-cache-control/src: selection.o
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/url.c dillo-cache-control/src/url.c
--- cvs/dillo/src/url.c	2003-04-23 01:58:30.000000000 +0300
+++ dillo-cache-control/src/url.c	2003-05-01 19:17:59.000000000 +0300
@@ -180,7 +180,7 @@ void a_Url_free(DilloUrl *url)
  * Resolve the URL as RFC2396 suggests.
  */
 static GString *Url_resolve_relative(const gchar *RelStr,
-                                     DilloUrl *BaseUrlPar,
+                                     DilloUrl **BaseUrlPar,
                                      const gchar *BaseStr)
 {
    gchar *p, *s, *e;
@@ -191,10 +191,9 @@ static GString *Url_resolve_relative(con
    /* parse relative URL */
    RelUrl = Url_object_new(RelStr);
 
-   if (BaseUrlPar) {
-      BaseUrl = BaseUrlPar;
-   } else if (RelUrl->scheme == NULL) {
-      /* only required when there's no <scheme> in RelStr */
+   if (*BaseUrlPar) {
+      BaseUrl = *BaseUrlPar;
+   } else {
       BaseUrl = Url_object_new(BaseStr);
    }
 
@@ -302,11 +301,14 @@ static GString *Url_resolve_relative(con
 done:
    g_string_free(Path, TRUE);
    a_Url_free(RelUrl);
-   if (BaseUrl != BaseUrlPar)
-      a_Url_free(BaseUrl);
+   *BaseUrlPar = BaseUrl;
    return SolvedUrl;
 }
 
+gboolean strcamp_i_eq(const gchar* s1, const gchar* s2) {
+   return URL_STRCAMP_I_EQ(s1, s2);
+}
+
 /*
  *  Transform (and resolve) an URL string into the respective DilloURL.
  *  If URL  =  "http://dillo.sf.net:8080/index.html?long#part2"
@@ -332,7 +334,7 @@ done:
 DilloUrl* a_Url_new(const gchar *url_str, const gchar *base_url,
                     gint flags, gint pos)
 {
-   DilloUrl *url;
+   DilloUrl *url, *BaseUrl = NULL;
    gchar *urlstring, *p, *s, *new_url = NULL;
    GString *SolvedUrl;
 
@@ -360,16 +362,23 @@ DilloUrl* a_Url_new(const gchar *url_str
    }
 
    /* Resolve the URL */
-   SolvedUrl = Url_resolve_relative(urlstring, NULL, base_url);
+   SolvedUrl = Url_resolve_relative(urlstring, &BaseUrl, base_url);
    DEBUG_MSG(2, "SolvedUrl = %s\n", SolvedUrl->str);
    g_free(new_url);
-   g_return_val_if_fail (SolvedUrl != NULL, NULL);
+   if (!SolvedUrl) {
+      a_Url_free(BaseUrl);
+      return NULL;
+   }
 
    /* Fill url data */
    url = Url_object_new(SolvedUrl->str);
+   if (BaseUrl && !strcamp_i_eq(URL_HOST_(url), URL_HOST_(BaseUrl))) {
+      flags |= URL_OnOtherHost;
+   }
    url->url_string = SolvedUrl;
    url->flags = flags;
    url->scrolling_position = pos;
+   a_Url_free(BaseUrl);
 
    return url;
 }
diff -pru -x CVS -x configure -x 'aclocal*' -x 'Makefile*' -x config.h.in cvs/dillo/src/url.h dillo-cache-control/src/url.h
--- cvs/dillo/src/url.h	2002-12-17 15:01:35.000000000 +0200
+++ dillo-cache-control/src/url.h	2003-05-01 19:17:59.000000000 +0300
@@ -41,6 +41,10 @@
 #define URL_ReloadIncomplete    (1 << 9)
 #define URL_SpamSafe            (1 << 10)
 
+#define URL_MustCache           (1 << 11)
+#define URL_IsImage             (1 << 12)
+#define URL_OnOtherHost         (1 << 13)
+
 /*
  * Access methods to fields inside DilloURL
  * (these macros MAY return NULL)
Only in dillo-cache-control/src: url.o
Only in dillo-cache-control/src: web.o
Only in dillo-cache-control: stamp-h1
