]>
Commit | Line | Data |
---|---|---|
43ae1d95 | 1 | /* |
77b1029d | 2 | * Copyright (C) 1996-2020 The Squid Software Foundation and contributors |
43ae1d95 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
43ae1d95 | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 86 ESI processing */ |
10 | ||
582c2af2 | 11 | #include "squid.h" |
454e8283 | 12 | |
13 | /* MS Visual Studio Projects are monolithic, so we need the following | |
14 | * #if to exclude the ESI code from compile process when not needed. | |
15 | */ | |
16 | #if (USE_SQUID_ESI == 1) | |
17 | ||
602d9612 | 18 | #include "client_side_request.h" |
f99c2cfe | 19 | #include "esi/Context.h" |
d3dddfb5 | 20 | #include "http/Stream.h" |
43ae1d95 | 21 | #include "Store.h" |
43ae1d95 | 22 | |
23 | void | |
24 | ESIContext::updateCachedAST() | |
25 | { | |
26 | assert (http); | |
924f73bc | 27 | assert (http->storeEntry()); |
43ae1d95 | 28 | |
29 | if (hasCachedAST()) { | |
bf8fe701 | 30 | debugs(86, 5, "ESIContext::updateCachedAST: not updating AST cache for entry " << |
31 | http->storeEntry() << " from ESI Context " << this << | |
32 | " as there is already a cached AST."); | |
33 | ||
43ae1d95 | 34 | return; |
35 | } | |
36 | ||
37 | ESIElement::Pointer treeToCache = tree->makeCacheable(); | |
bf8fe701 | 38 | debugs(86, 5, "ESIContext::updateCachedAST: Updating AST cache for entry " << |
39 | http->storeEntry() << " with current value " << | |
40 | http->storeEntry()->cachedESITree.getRaw() << " to new value " << | |
41 | treeToCache.getRaw()); | |
43ae1d95 | 42 | |
924f73bc | 43 | if (http->storeEntry()->cachedESITree.getRaw()) |
44 | http->storeEntry()->cachedESITree->finish(); | |
43ae1d95 | 45 | |
924f73bc | 46 | http->storeEntry()->cachedESITree = treeToCache; |
43ae1d95 | 47 | |
48 | treeToCache = NULL; | |
49 | } | |
50 | ||
51 | bool | |
52 | ESIContext::hasCachedAST() const | |
53 | { | |
54 | assert (http); | |
924f73bc | 55 | assert (http->storeEntry()); |
43ae1d95 | 56 | |
924f73bc | 57 | if (http->storeEntry()->cachedESITree.getRaw()) { |
bf8fe701 | 58 | debugs(86, 5, "ESIContext::hasCachedAST: " << this << |
59 | " - Cached AST present in store entry " << http->storeEntry() << "."); | |
43ae1d95 | 60 | return true; |
61 | } else { | |
bf8fe701 | 62 | debugs(86, 5, "ESIContext::hasCachedAST: " << this << |
63 | " - Cached AST not present in store entry " << http->storeEntry() << "."); | |
43ae1d95 | 64 | return false; |
65 | } | |
66 | } | |
67 | ||
68 | void | |
69 | ESIContext::getCachedAST() | |
70 | { | |
71 | if (cachedASTInUse) | |
72 | return; | |
73 | ||
74 | assert (hasCachedAST()); | |
75 | ||
76 | assert (varState); | |
77 | ||
78 | parserState.popAll(); | |
79 | ||
924f73bc | 80 | tree = http->storeEntry()->cachedESITree->makeUsable (this, *varState); |
43ae1d95 | 81 | |
82 | cachedASTInUse = true; | |
83 | } | |
924f73bc | 84 | |
85 | void | |
86 | ESIContext::setErrorMessage(char const *anError) | |
87 | { | |
88 | if (!errormessage) | |
86c63190 | 89 | errormessage = xstrdup(anError); |
924f73bc | 90 | } |
454e8283 | 91 | |
92 | #endif /* USE_SQUID_ESI == 1 */ | |
f53969cc | 93 |