--------------------- PatchSet 2393 Date: 2001/05/28 14:20:19 Author: hno Branch: etag Tag: (none) Log: Vary tagging separated from the main store functions. Members: src/store.c:1.12->1.12.14.1 Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.12 retrieving revision 1.12.14.1 diff -u -r1.12 -r1.12.14.1 --- squid/src/store.c 14 Apr 2001 00:31:02 -0000 1.12 +++ squid/src/store.c 28 May 2001 14:20:19 -0000 1.12.14.1 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.12 2001/04/14 00:31:02 squidadm Exp $ + * $Id: store.c,v 1.12.14.1 2001/05/28 14:20:19 hno Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -374,6 +374,26 @@ storeHashInsert(e, newkey); } +static void +storeAddVary(const char *url, const char *log_url, const method_t method, const cache_key *key, const char *etag, const char *vary, const char *vary_headers) +{ + StoreEntry *pe; + if (!storeGetPublic(url, method)) { + /* Create "vary" base object */ + http_version_t version; + pe = storeCreateEntry(url, log_url, null_request_flags, method); + httpBuildVersion(&version, 1, 0); + httpReplySetHeaders(pe->mem_obj->reply, version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); + httpHeaderPutStr(&pe->mem_obj->reply->header, HDR_VARY, vary); + storeSetPublicKey(pe); + httpReplySwapOut(pe->mem_obj->reply, pe); + storeBufferFlush(pe); + storeTimestampsSet(pe); + storeComplete(pe); + storeUnlockObject(pe); + } +} + void storeSetPublicKey(StoreEntry * e) { @@ -419,35 +439,20 @@ if (!request->vary_headers) request->vary_headers = xstrdup(httpMakeVaryMark(request, mem->reply)); } - if (mem->vary_headers && !storeGetPublic(mem->url, mem->method)) { - /* Create "vary" base object */ - http_version_t version; - String vary; - pe = storeCreateEntry(mem->url, mem->log_url, request->flags, request->method); - httpBuildVersion(&version, 1, 0); - httpReplySetHeaders(pe->mem_obj->reply, version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); - vary = httpHeaderGetList(&mem->reply->header, HDR_VARY); - if (strBuf(vary)) { - httpHeaderPutStr(&pe->mem_obj->reply->header, HDR_VARY, strBuf(vary)); - stringClean(&vary); - } + newkey = storeKeyPublicByRequest(mem->request); + if (mem->vary_headers) { + String vary = StringNull; #if X_ACCELERATOR_VARY vary = httpHeaderGetList(&mem->reply->header, HDR_X_ACCELERATOR_VARY); - if (strBuf(vary)) { - httpHeaderPutStr(&pe->mem_obj->reply->header, HDR_X_ACCELERATOR_VARY, strBuf(vary)); - stringClean(&vary); - } + if (!strBuf(vary)) #endif - storeSetPublicKey(pe); - httpReplySwapOut(pe->mem_obj->reply, pe); - storeBufferFlush(pe); - storeTimestampsSet(pe); - storeComplete(pe); - storeUnlockObject(pe); + vary = httpHeaderGetList(&mem->reply->header, HDR_VARY); + storeAddVary(mem->url, mem->log_url, mem->method, newkey, httpHeaderGetStr(&mem->reply->header, HDR_ETAG), strBuf(vary), mem->vary_headers); + stringClean(&vary); } - newkey = storeKeyPublicByRequest(mem->request); - } else + } else { newkey = storeKeyPublic(mem->url, mem->method); + } if ((e2 = (StoreEntry *) hash_lookup(store_table, newkey))) { debug(20, 3) ("storeSetPublicKey: Making old '%s' private.\n", mem->url); storeSetPrivateKey(e2);