]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Finally finished the bit of HTCP that checks the query HTTP headers
authorwessels <>
Thu, 10 Jun 1999 12:10:30 +0000 (12:10 +0000)
committerwessels <>
Thu, 10 Jun 1999 12:10:30 +0000 (12:10 +0000)
for freshness.

src/htcp.cc
src/protos.h
src/refresh.cc

index bde07fd43d08163479889895b8a9044609492c0a..e64a1a9c64391eebfba813eace36186d11c78921 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: htcp.cc,v 1.26 1998/10/08 20:10:21 wessels Exp $
+ * $Id: htcp.cc,v 1.27 1999/06/10 06:10:30 wessels Exp $
  *
  * DEBUG: section 31    Hypertext Caching Protocol
  * AUTHOR: Duane Wesssels
@@ -180,6 +180,7 @@ static void htcpSend(const char *buf, int len, struct sockaddr_in *to);
 static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, struct sockaddr_in *);
 static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, struct sockaddr_in *from);
 static void htcpHandleTstResponse(htcpDataHeader *, char *, int, struct sockaddr_in *);
+static StoreEntry *htcpCheckHit(const htcpSpecifier *);
 
 static void
 htcpHexdump(const char *tag, const char *s, int sz)
@@ -600,6 +601,27 @@ htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
     debug(31, 3) ("htcpHandleNop: Unimplemented\n");
 }
 
+static StoreEntry *
+htcpCheckHit(const htcpSpecifier * s)
+{
+    request_t *request;
+    method_t m = urlParseMethod(s->method);
+    StoreEntry *e = storeGetPublic(s->uri, m);
+    if (NULL == e)
+       return NULL;
+    if (!storeEntryValidToSend(e))
+       return NULL;
+    request = urlParse(m, s->uri);
+    if (NULL == request)
+       return NULL;
+    if (!httpRequestParseHeader(request, s->req_hdrs))
+       e = NULL;
+    else if (refreshCheckHTCP(e, request))
+       e = NULL;
+    requestDestroy(request);
+    return e;
+}
+
 static void
 htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
 {
@@ -655,7 +677,6 @@ htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct sockaddr_i
     /* buf should be a SPECIFIER */
     htcpSpecifier *s;
     StoreEntry *e;
-    method_t m;
     if (sz == 0) {
        debug(31, 3) ("htcpHandleTst: nothing to do\n");
        return;
@@ -671,21 +692,11 @@ htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct sockaddr_i
        s->method,
        s->uri,
        s->version);
-    m = urlParseMethod(s->method);
     debug(31, 3) ("htcpHandleTstRequest: %s\n", s->req_hdrs);
-    e = storeGetPublic(s->uri, m);
-    if (NULL == e) {
-       /* cache miss */
-       htcpTstReply(dhdr, NULL, NULL, from);
-#if WIP
-    } else if (!checkHeaders()) {
-       /* refresh/other miss */
-       htcpTstReply(dhdr, NULL, NULL, from);
-#endif
-    } else {
-       /* hit */
-       htcpTstReply(dhdr, e, s, from);
-    }
+    if ((e = htcpCheckHit(s)))
+       htcpTstReply(dhdr, e, s, from);         /* hit */
+    else
+       htcpTstReply(dhdr, NULL, NULL, from);   /* cache miss */
     htcpFreeSpecifier(s);
 }
 
index 635cf8ed04ca50f98ff36247a46d5b81566c9f21..3e0c4237fc3865cf93ca2d8a9b2a603c379c4a51 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.337 1999/05/27 03:21:37 wessels Exp $
+ * $Id: protos.h,v 1.338 1999/06/10 06:10:32 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -698,6 +698,7 @@ extern void refreshAddToList(const char *, int, time_t, int, time_t);
 extern int refreshIsCachable(const StoreEntry *);
 extern int refreshCheckHTTP(const StoreEntry *, request_t *);
 extern int refreshCheckICP(const StoreEntry *, request_t *);
+extern int refreshCheckHTCP(const StoreEntry *, request_t *);
 extern int refreshCheckDigest(const StoreEntry *, time_t delta);
 extern time_t getMaxAge(const char *url);
 extern void refreshInit(void);
index 973d6f8377cfa146ab714918c9e0bda0c6ee1e59..8ae1e57dc7d48e11104bc5894e3b9d52f6fbc7c4 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: refresh.cc,v 1.48 1999/05/03 20:37:49 wessels Exp $
+ * $Id: refresh.cc,v 1.49 1999/06/10 06:10:34 wessels Exp $
  *
  * DEBUG: section 22    Refresh Calculation
  * AUTHOR: Harvest Derived
@@ -41,7 +41,7 @@
 #include "squid.h"
 
 typedef enum {
-    rcHTTP, rcICP, rcCDigest, rcStore, rcCount
+    rcHTTP, rcICP, rcHTCP, rcCDigest, rcStore, rcCount
 } refreshCountsEnum;
 
 static struct RefreshCounts {
@@ -298,6 +298,12 @@ refreshCheckICP(const StoreEntry * entry, request_t * request)
     return refreshCheck(entry, request, 30, &refreshCounts[rcICP]);
 }
 
+int
+refreshCheckHTCP(const StoreEntry * entry, request_t * request)
+{
+    return refreshCheck(entry, request, 10, &refreshCounts[rcHTCP]);
+}
+
 int
 refreshCheckDigest(const StoreEntry * entry, time_t delta)
 {
@@ -385,6 +391,7 @@ refreshInit()
     memset(refreshCounts, 0, sizeof(refreshCounts));
     refreshCounts[rcHTTP].proto = "HTTP";
     refreshCounts[rcICP].proto = "ICP";
+    refreshCounts[rcHTCP].proto = "HTCP";
     refreshCounts[rcStore].proto = "On Store";
     refreshCounts[rcCDigest].proto = "Cache Digests";