]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Daily Ed Knowles patch, plus DW cleanup
authorwessels <>
Fri, 8 Nov 1996 01:53:15 +0000 (01:53 +0000)
committerwessels <>
Fri, 8 Nov 1996 01:53:15 +0000 (01:53 +0000)
src/http.cc
src/store.cc
src/tools.cc

index b5b05f2024063ad50674b3538c2cd0eef2fe63e8..f2522b4e8bfedb240162d4e23137fe1276363ae5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.cc,v 1.98 1996/11/06 23:14:39 wessels Exp $
+ * $Id: http.cc,v 1.99 1996/11/07 18:53:15 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
 
 #define HTTP_DELETE_GAP   (1<<18)
 
+typedef enum {
+    SCC_PUBLIC,
+    SCC_PRIVATE,
+    SCC_NOCACHE,
+    SCC_NOSTORE,
+    SCC_NOTRANSFORM,
+    SCC_MUSTREVALIDATE,
+    SCC_PROXYREVALIDATE,
+    SCC_MAXAGE,
+    SCC_ENUM_END
+} http_server_cc_t;
+
+typedef enum {
+    CCC_NOCACHE,
+    CCC_NOSTORE,
+    CCC_MAXAGE,
+    CCC_MAXSTALE,
+    CCC_MINFRESH,
+    CCC_ONLYIFCACHED,
+    CCC_ENUM_END
+} http_client_cc_t;
+
+char *HttpServerCCStr[] =
+{
+    "public",
+    "private",
+    "no-cache",
+    "no-store",
+    "no-transform",
+    "must-revalidate",
+    "proxy-revalidate",
+    "max-age",
+    "NONE"
+};
+
 static struct {
     int parsed;
     int date;
@@ -114,11 +149,7 @@ static struct {
     int exp;
     int clen;
     int ctype;
-    struct {
-       int private;
-       int cachable;
-       int nocache;
-    } cc;
+    int cc[SCC_ENUM_END];
 } ReplyHeaderStats;
 
 static void httpStateFree _PARAMS((int fd, void *));
@@ -218,6 +249,7 @@ httpParseHeaders(const char *buf, struct _http_reply *reply)
     char *headers = NULL;
     char *t = NULL;
     char *s = NULL;
+    int delta;
 
     ReplyHeaderStats.parsed++;
     headers = xstrdup(buf);
@@ -264,15 +296,22 @@ httpParseHeaders(const char *buf, struct _http_reply *reply)
            }
        } else if (!strncasecmp(t, "Cache-Control:", 14)) {
            if ((t = strtok(NULL, w_space))) {
-               if (!strncasecmp(t, "private", 7)) {
-                   reply->cache_control |= HTTP_CC_PRIVATE;
-                   ReplyHeaderStats.cc.private++;
-               } else if (!strncasecmp(t, "cachable", 8)) {
-                   reply->cache_control |= HTTP_CC_CACHABLE;
-                   ReplyHeaderStats.cc.cachable++;
+               if (!strncasecmp(t, "public", 6)) {
+                   EBIT_SET(reply->cache_control, SCC_PUBLIC);
+                   ReplyHeaderStats.cc[SCC_PUBLIC]++;
+               } else if (!strncasecmp(t, "private", 7)) {
+                   EBIT_SET(reply->cache_control, SCC_PRIVATE);
+                   ReplyHeaderStats.cc[SCC_PRIVATE]++;
                } else if (!strncasecmp(t, "no-cache", 8)) {
-                   reply->cache_control |= HTTP_CC_NOCACHE;
-                   ReplyHeaderStats.cc.nocache++;
+                   EBIT_SET(reply->cache_control, SCC_NOCACHE);
+                   ReplyHeaderStats.cc[SCC_NOCACHE]++;
+               } else if (!strncasecmp(t, "max-age", 7)) {
+                   if ((t = strchr(t, '='))) {
+                       delta = atoi(++t);
+                       EBIT_SET(reply->cache_control, SCC_MAXAGE);
+                       ReplyHeaderStats.cc[SCC_MAXAGE]++;
+                       strcpy(reply->expires, mkrfc1123(squid_curtime + delta));
+                   }
                }
            }
        }
@@ -344,9 +383,9 @@ httpProcessReplyHeader(HttpStateData * httpState, const char *buf, int size)
        case 301:               /* Moved Permanently */
        case 410:               /* Gone */
            /* don't cache objects from neighbors w/o LMT, Date, or Expires */
-           if (BIT_TEST(reply->cache_control, HTTP_CC_PRIVATE))
+           if (EBIT_TEST(reply->cache_control, SCC_PRIVATE))
                httpMakePrivate(entry);
-           else if (BIT_TEST(reply->cache_control, HTTP_CC_NOCACHE))
+           else if (EBIT_TEST(reply->cache_control, SCC_NOCACHE))
                httpMakePrivate(entry);
            else if (*reply->date)
                httpMakePublic(entry);
@@ -809,25 +848,24 @@ httpStart(int unusedfd,
 void
 httpReplyHeaderStats(StoreEntry * entry)
 {
+    http_server_cc_t i;
     storeAppendPrintf(entry, open_bracket);
-    storeAppendPrintf(entry, "{HTTP Reply Headers}\n");
-    storeAppendPrintf(entry, "{Headers parsed: %d}\n",
+    storeAppendPrintf(entry, "{HTTP Reply Headers:}\n");
+    storeAppendPrintf(entry, "{       Headers parsed: %d}\n",
        ReplyHeaderStats.parsed);
-    storeAppendPrintf(entry, "{          Date: %d}\n",
+    storeAppendPrintf(entry, "{                 Date: %d}\n",
        ReplyHeaderStats.date);
-    storeAppendPrintf(entry, "{ Last-Modified: %d}\n",
+    storeAppendPrintf(entry, "{        Last-Modified: %d}\n",
        ReplyHeaderStats.lm);
-    storeAppendPrintf(entry, "{       Expires: %d}\n",
+    storeAppendPrintf(entry, "{              Expires: %d}\n",
        ReplyHeaderStats.exp);
-    storeAppendPrintf(entry, "{  Content-Type: %d}\n",
+    storeAppendPrintf(entry, "{         Content-Type: %d}\n",
        ReplyHeaderStats.ctype);
-    storeAppendPrintf(entry, "{Content-Length: %d}\n",
+    storeAppendPrintf(entry, "{       Content-Length: %d}\n",
        ReplyHeaderStats.clen);
-    storeAppendPrintf(entry, "{Cache-Control Private: %d}\n",
-       ReplyHeaderStats.cc.private);
-    storeAppendPrintf(entry, "{Cache-Control Cachable: %d}\n",
-       ReplyHeaderStats.cc.cachable);
-    storeAppendPrintf(entry, "{Cache-Control Nocache: %d}\n",
-       ReplyHeaderStats.cc.nocache);
+    for (i = 0; i < SCC_ENUM_END; i++)
+       storeAppendPrintf(entry, "{Cache-Control %7.7s: %d}\n",
+           HttpServerCCStr[i],
+           ReplyHeaderStats.cc[i]);
     storeAppendPrintf(entry, close_bracket);
 }
index 0116e766f28a20894f89c2c91e829e210d40c36a..78b5dd9a14d5a01304ba95a5cbbbdc21e55a8364 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.154 1996/11/07 00:30:05 wessels Exp $
+ * $Id: store.cc,v 1.155 1996/11/07 18:53:18 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -793,7 +793,7 @@ storeCreateEntry(const char *url,
     /* allocate client list */
     mem->nclients = MIN_CLIENT;
     mem->clients = xcalloc(mem->nclients, sizeof(struct _store_client));
-    for (i=0; i<mem->nclients; i++)
+    for (i = 0; i < mem->nclients; i++)
        mem->clients[i].fd = -1;
     /* storeLog(STORE_LOG_CREATE, e); */
     return e;
@@ -2193,8 +2193,8 @@ storeClientListAdd(StoreEntry * e, int fd, int last_offset)
     if (mem->clients == NULL) {
        mem->nclients = MIN_CLIENT;
        mem->clients = xcalloc(mem->nclients, sizeof(struct _store_client));
-        for (i=0; i<mem->nclients; i++)
-           mem->clients[i].fd = -1;
+       for (i = 0; i < mem->nclients; i++)
+           mem->clients[i].fd = -1;
     }
     for (i = 0; i < mem->nclients; i++) {
        if (mem->clients[i].fd == -1)
index 576eaa309a2531328c3da14de8cbff39408f3900..19bfc7a252b813f4acf91caa482f2276cfca5dc4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.81 1996/11/06 23:15:04 wessels Exp $
+ * $Id: tools.cc,v 1.82 1996/11/07 18:53:19 wessels Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -216,9 +216,9 @@ PrintRusage(void (*f) (void), FILE * lf)
     getrusage(RUSAGE_SELF, &rusage);
     fprintf(lf, "CPU Usage: user %d sys %d\n",
        (int) rusage.ru_utime.tv_sec, (int) rusage.ru_stime.tv_sec);
-#ifdef _SQUID_SGI_
+#if defined(_SQUID_SGI_) || defined(_SQUID_OSF_)
     fprintf(lf, "Memory Usage: rss %ld KB\n", rusage.ru_maxrss);
-#else
+#else /* _SQUID_SGI_ */
     fprintf(lf, "Memory Usage: rss %ld KB\n",
        (rusage.ru_maxrss * getpagesize()) >> 10);
 #endif /* _SQUID_SGI_ */