]>
Commit | Line | Data |
---|---|---|
c824c43b | 1 | |
2 | /* | |
c824c43b | 3 | * |
4 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
5 | * ---------------------------------------------------------- | |
6 | * | |
7 | * Squid is the result of efforts by numerous individuals from | |
8 | * the Internet community; see the CONTRIBUTORS file for full | |
9 | * details. Many organizations have provided support for Squid's | |
10 | * development; see the SPONSORS file for full details. Squid is | |
11 | * Copyrighted (C) 2001 by the Regents of the University of | |
12 | * California; see the COPYRIGHT file for full details. Squid | |
13 | * incorporates software developed and/or copyrighted by other | |
14 | * sources; see the CREDITS file for full details. | |
15 | * | |
16 | * This program is free software; you can redistribute it and/or modify | |
17 | * it under the terms of the GNU General Public License as published by | |
18 | * the Free Software Foundation; either version 2 of the License, or | |
19 | * (at your option) any later version. | |
26ac0430 | 20 | * |
c824c43b | 21 | * This program is distributed in the hope that it will be useful, |
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | * GNU General Public License for more details. | |
26ac0430 | 25 | * |
c824c43b | 26 | * You should have received a copy of the GNU General Public License |
27 | * along with this program; if not, write to the Free Software | |
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
29 | * | |
30 | */ | |
31 | ||
32 | #ifndef SQUID_ICAPLAUNCHER_H | |
33 | #define SQUID_ICAPLAUNCHER_H | |
34 | ||
26cc52cb | 35 | #include "adaptation/icap/ServiceRep.h" |
602d9612 A |
36 | #include "adaptation/Initiate.h" |
37 | #include "adaptation/Initiator.h" | |
c824c43b | 38 | |
39 | /* | |
40 | * The ICAP Launcher starts an ICAP transaction. If the transaction fails | |
41 | * due to what looks like a persistent connection race condition, the launcher | |
42 | * starts a new ICAP transaction using a freshly opened connection. | |
43 | * | |
44 | * ICAPLauncher and one or more ICAP transactions initiated by it form an | |
45 | * ICAP "query". | |
46 | * | |
47 | * An ICAP Initiator deals with the ICAP Launcher and not an individual ICAP | |
48 | * transaction because the latter may disappear and be replaced by another | |
49 | * transaction. | |
50 | * | |
51 | * Specific ICAP launchers implement the createXaction() method to create | |
52 | * REQMOD, RESPMOD, or OPTIONS transaction from initiator-supplied data. | |
53 | * | |
26ac0430 AJ |
54 | * TODO: This class might be the right place to initiate ICAP ACL checks or |
55 | * implement more sophisticated ICAP transaction handling like chaining of | |
c824c43b | 56 | * ICAP transactions. |
57 | */ | |
58 | ||
af6a12ee AJ |
59 | namespace Adaptation |
60 | { | |
e1381638 AJ |
61 | namespace Icap |
62 | { | |
26cc52cb AR |
63 | |
64 | class Xaction; | |
3ff65596 | 65 | class XactAbortInfo; |
26cc52cb AR |
66 | |
67 | // Note: Initiate must be the first parent for cbdata to work. We use | |
68 | // a temporary InitaitorHolder/toCbdata hacks and do not call cbdata | |
c824c43b | 69 | // operations on the initiator directly. |
26cc52cb | 70 | class Launcher: public Adaptation::Initiate, public Adaptation::Initiator |
c824c43b | 71 | { |
72 | public: | |
4299f876 | 73 | Launcher(const char *aTypeName, Adaptation::ServicePointer &aService); |
26cc52cb | 74 | virtual ~Launcher(); |
c824c43b | 75 | |
0bef8dd7 | 76 | // Adaptation::Initiate: asynchronous communication with the initiator |
c824c43b | 77 | void noteInitiatorAborted(); |
78 | ||
0bef8dd7 | 79 | // Adaptation::Initiator: asynchronous communication with the current transaction |
3af10ac0 | 80 | virtual void noteAdaptationAnswer(const Answer &answer); |
4299f876 | 81 | virtual void noteXactAbort(XactAbortInfo info); |
3ff65596 AR |
82 | |
83 | private: | |
84 | bool canRetry(XactAbortInfo &info) const; //< true if can retry in the case of persistent connection failures | |
e1381638 | 85 | bool canRepeat(XactAbortInfo &info) const; //< true if can repeat in the case of no or unsatisfactory response |
c824c43b | 86 | |
c824c43b | 87 | protected: |
0bef8dd7 | 88 | // Adaptation::Initiate API implementation |
c824c43b | 89 | virtual void start(); |
90 | virtual bool doneAll() const; | |
91 | virtual void swanSong(); | |
92 | ||
93 | // creates the right ICAP transaction using stored configuration params | |
26cc52cb | 94 | virtual Xaction *createXaction() = 0; |
c824c43b | 95 | |
3ff65596 | 96 | void launchXaction(const char *xkind); |
c824c43b | 97 | |
a22e6cd3 | 98 | Adaptation::ServicePointer theService; ///< ICAP service for all launches |
4299f876 | 99 | CbcPointer<Initiate> theXaction; ///< current ICAP transaction |
c824c43b | 100 | int theLaunches; // the number of transaction launches |
101 | }; | |
102 | ||
e1381638 | 103 | /// helper class to pass information about aborted ICAP requests to |
3ff65596 | 104 | /// the Adaptation::Icap::Launcher class |
e1381638 AJ |
105 | class XactAbortInfo |
106 | { | |
3ff65596 AR |
107 | public: |
108 | XactAbortInfo(HttpRequest *anIcapRequest, HttpReply *anIcapReply, | |
109 | bool beRetriable, bool beRepeatable); | |
110 | XactAbortInfo(const XactAbortInfo &); | |
111 | ~XactAbortInfo(); | |
112 | ||
4299f876 AR |
113 | std::ostream &print(std::ostream &os) const { |
114 | return os << isRetriable << ',' << isRepeatable; | |
115 | } | |
116 | ||
3ff65596 AR |
117 | HttpRequest *icapRequest; |
118 | HttpReply *icapReply; | |
119 | bool isRetriable; | |
120 | bool isRepeatable; | |
e1381638 | 121 | |
3ff65596 AR |
122 | private: |
123 | XactAbortInfo &operator =(const XactAbortInfo &); // undefined | |
124 | }; | |
125 | ||
4299f876 AR |
126 | inline |
127 | std::ostream & | |
4cb2536f A |
128 | operator <<(std::ostream &os, const XactAbortInfo &xai) |
129 | { | |
4299f876 | 130 | return xai.print(os); |
3ff65596 AR |
131 | } |
132 | ||
26cc52cb AR |
133 | } // namespace Icap |
134 | } // namespace Adaptation | |
135 | ||
c824c43b | 136 | #endif /* SQUID_ICAPLAUNCHER_H */ |