]>
Commit | Line | Data |
---|---|---|
43ae1d95 | 1 | |
2 | /* | |
43ae1d95 | 3 | * DEBUG: section 86 ESI processing |
4 | * AUTHOR: Robert Collins | |
5 | * | |
6 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
7 | * ---------------------------------------------------------- | |
8 | * | |
9 | * Squid is the result of efforts by numerous individuals from | |
10 | * the Internet community; see the CONTRIBUTORS file for full | |
11 | * details. Many organizations have provided support for Squid's | |
12 | * development; see the SPONSORS file for full details. Squid is | |
13 | * Copyrighted (C) 2001 by the Regents of the University of | |
14 | * California; see the COPYRIGHT file for full details. Squid | |
15 | * incorporates software developed and/or copyrighted by other | |
16 | * sources; see the CREDITS file for full details. | |
17 | * | |
18 | * This program is free software; you can redistribute it and/or modify | |
19 | * it under the terms of the GNU General Public License as published by | |
20 | * the Free Software Foundation; either version 2 of the License, or | |
21 | * (at your option) any later version. | |
26ac0430 | 22 | * |
43ae1d95 | 23 | * This program is distributed in the hope that it will be useful, |
24 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 | * GNU General Public License for more details. | |
26ac0430 | 27 | * |
43ae1d95 | 28 | * You should have received a copy of the GNU General Public License |
29 | * along with this program; if not, write to the Free Software | |
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
31 | * | |
32 | */ | |
33 | ||
582c2af2 | 34 | #include "squid.h" |
454e8283 | 35 | |
36 | /* MS Visual Studio Projects are monolithic, so we need the following | |
37 | * #if to exclude the ESI code from compile process when not needed. | |
38 | */ | |
39 | #if (USE_SQUID_ESI == 1) | |
40 | ||
602d9612 | 41 | #include "client_side_request.h" |
f99c2cfe | 42 | #include "esi/Context.h" |
43ae1d95 | 43 | #include "Store.h" |
43ae1d95 | 44 | |
45 | void | |
46 | ESIContext::updateCachedAST() | |
47 | { | |
48 | assert (http); | |
924f73bc | 49 | assert (http->storeEntry()); |
43ae1d95 | 50 | |
51 | if (hasCachedAST()) { | |
bf8fe701 | 52 | debugs(86, 5, "ESIContext::updateCachedAST: not updating AST cache for entry " << |
53 | http->storeEntry() << " from ESI Context " << this << | |
54 | " as there is already a cached AST."); | |
55 | ||
43ae1d95 | 56 | return; |
57 | } | |
58 | ||
59 | ESIElement::Pointer treeToCache = tree->makeCacheable(); | |
bf8fe701 | 60 | debugs(86, 5, "ESIContext::updateCachedAST: Updating AST cache for entry " << |
61 | http->storeEntry() << " with current value " << | |
62 | http->storeEntry()->cachedESITree.getRaw() << " to new value " << | |
63 | treeToCache.getRaw()); | |
43ae1d95 | 64 | |
924f73bc | 65 | if (http->storeEntry()->cachedESITree.getRaw()) |
66 | http->storeEntry()->cachedESITree->finish(); | |
43ae1d95 | 67 | |
924f73bc | 68 | http->storeEntry()->cachedESITree = treeToCache; |
43ae1d95 | 69 | |
70 | treeToCache = NULL; | |
71 | } | |
72 | ||
73 | bool | |
74 | ESIContext::hasCachedAST() const | |
75 | { | |
76 | assert (http); | |
924f73bc | 77 | assert (http->storeEntry()); |
43ae1d95 | 78 | |
924f73bc | 79 | if (http->storeEntry()->cachedESITree.getRaw()) { |
bf8fe701 | 80 | debugs(86, 5, "ESIContext::hasCachedAST: " << this << |
81 | " - Cached AST present in store entry " << http->storeEntry() << "."); | |
43ae1d95 | 82 | return true; |
83 | } else { | |
bf8fe701 | 84 | debugs(86, 5, "ESIContext::hasCachedAST: " << this << |
85 | " - Cached AST not present in store entry " << http->storeEntry() << "."); | |
43ae1d95 | 86 | return false; |
87 | } | |
88 | } | |
89 | ||
90 | void | |
91 | ESIContext::getCachedAST() | |
92 | { | |
93 | if (cachedASTInUse) | |
94 | return; | |
95 | ||
96 | assert (hasCachedAST()); | |
97 | ||
98 | assert (varState); | |
99 | ||
100 | parserState.popAll(); | |
101 | ||
924f73bc | 102 | tree = http->storeEntry()->cachedESITree->makeUsable (this, *varState); |
43ae1d95 | 103 | |
104 | cachedASTInUse = true; | |
105 | } | |
924f73bc | 106 | |
107 | void | |
108 | ESIContext::setErrorMessage(char const *anError) | |
109 | { | |
110 | if (!errormessage) | |
111 | errormessage = xstrdup (anError); | |
112 | } | |
454e8283 | 113 | |
114 | #endif /* USE_SQUID_ESI == 1 */ |