--------------------- PatchSet 5058 Date: 2002/09/20 05:07:34 Author: rbcollins Branch: fixrange Tag: (none) Log: extract method on cache_control tests Members: src/http.c:1.24.2.3->1.24.2.4 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.24.2.3 retrieving revision 1.24.2.4 diff -u -r1.24.2.3 -r1.24.2.4 --- squid/src/http.c 20 Sep 2002 04:05:02 -0000 1.24.2.3 +++ squid/src/http.c 20 Sep 2002 05:07:34 -0000 1.24.2.4 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.24.2.3 2002/09/20 04:05:02 rbcollins Exp $ + * $Id: http.c,v 1.24.2.4 2002/09/20 05:07:34 rbcollins Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -219,6 +219,21 @@ } } +int +cacheControlAllowsCaching(HttpHdrCc *cc) +{ + if (cc) { + const int cc_mask = cc->mask; + if (EBIT_TEST(cc_mask, CC_PRIVATE)) + return 0; + if (EBIT_TEST(cc_mask, CC_NO_CACHE)) + return 0; + if (EBIT_TEST(cc_mask, CC_NO_STORE)) + return 0; + } + return 1; +} + static int httpCachableReply(HttpStateData * httpState) { @@ -226,11 +241,7 @@ HttpHeader *hdr = &rep->header; const int cc_mask = (rep->cache_control) ? rep->cache_control->mask : 0; const char *v; - if (EBIT_TEST(cc_mask, CC_PRIVATE)) - return 0; - if (EBIT_TEST(cc_mask, CC_NO_CACHE)) - return 0; - if (EBIT_TEST(cc_mask, CC_NO_STORE)) + if (!cacheControlAllowsCaching(rep->cache_control)); return 0; if (httpState->request->flags.auth) { /*