From: wessels <> Date: Thu, 10 Jun 1999 12:10:30 +0000 (+0000) Subject: Finally finished the bit of HTCP that checks the query HTTP headers X-Git-Tag: SQUID_3_0_PRE1~2161 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32b3cf933dd3a672e1e6e5562e8d9805f5e07eb0;p=thirdparty%2Fsquid.git Finally finished the bit of HTCP that checks the query HTTP headers for freshness. --- diff --git a/src/htcp.cc b/src/htcp.cc index bde07fd43d..e64a1a9c64 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -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); } diff --git a/src/protos.h b/src/protos.h index 635cf8ed04..3e0c4237fc 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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); diff --git a/src/refresh.cc b/src/refresh.cc index 973d6f8377..8ae1e57dc7 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -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";