]>
Commit | Line | Data |
---|---|---|
774c051c | 1 | |
2 | /* | |
0c11e386 | 3 | * $Id$ |
774c051c | 4 | * |
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 | |
33ff9dbf | 16 | * sources; see the CREDITS file for full details. |
774c051c | 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. | |
c2f1edbd | 22 | * |
774c051c | 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. | |
c2f1edbd | 27 | * |
774c051c | 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 | ||
34 | #ifndef SQUID_ICAPOPTIONS_H | |
35 | #define SQUID_ICAPOPTIONS_H | |
36 | ||
37 | #include "squid.h" | |
008bb7a0 | 38 | #include "adaptation/icap/ServiceRep.h" |
774c051c | 39 | |
c99de607 | 40 | class wordlist; |
41 | ||
008bb7a0 AJ |
42 | namespace Adaptation { |
43 | namespace Icap { | |
44 | ||
774c051c | 45 | /* Maintains options supported by a given ICAP service. |
46 | * See RFC 3507, Section "4.10.2 OPTIONS Response". */ | |
47 | ||
008bb7a0 | 48 | class Options |
774c051c | 49 | { |
50 | ||
51 | public: | |
008bb7a0 AJ |
52 | typedef void GetCallback(void *data, Options *options); |
53 | static void Get(ServiceRep::Pointer &service, GetCallback *cb, void *data); | |
774c051c | 54 | |
55 | public: | |
008bb7a0 AJ |
56 | Options(); |
57 | ~Options(); | |
774c051c | 58 | |
59 | void configure(const HttpReply *reply); | |
60 | ||
61 | bool valid() const; | |
62 | bool fresh() const; | |
5f8252d2 | 63 | int ttl() const; |
774c051c | 64 | time_t expire() const; |
8eeb99bf | 65 | time_t timestamp() const { return theTimestamp; }; |
66 | ||
c99de607 | 67 | typedef enum { xferNone, xferPreview, xferIgnore, xferComplete } TransferKind; |
30abd221 | 68 | TransferKind transferKind(const String &urlPath) const; |
774c051c | 69 | |
70 | public: | |
71 | const char *error; // human-readable information; set iff !valid() | |
72 | ||
73 | // ICAP server MUST supply this info | |
eadded2e | 74 | Vector<ICAP::Method> methods; |
30abd221 | 75 | String istag; |
774c051c | 76 | |
77 | // ICAP server MAY supply this info. If not, Squid supplies defaults. | |
30abd221 | 78 | String service; |
79 | String serviceId; | |
774c051c | 80 | int max_connections; |
81 | bool allow204; | |
82 | int preview; | |
83 | ||
c99de607 | 84 | protected: |
85 | // Transfer-* extension list representation | |
86 | // maintains wordlist and does parsing/matching | |
c2f1edbd AJ |
87 | class TransferList |
88 | { | |
89 | public: | |
90 | TransferList(); | |
91 | ~TransferList(); | |
c99de607 | 92 | |
c2f1edbd | 93 | bool matches(const String &urlPath) const; |
c99de607 | 94 | |
c2f1edbd AJ |
95 | void parse(const String &buf, bool &foundStar); |
96 | void add(const char *extension); | |
97 | void report(int level, const char *prefix) const; | |
c99de607 | 98 | |
c2f1edbd AJ |
99 | public: |
100 | wordlist *extensions; // TODO: optimize with a hash of some sort | |
101 | const char *name; // header name, mostly for debugging | |
102 | TransferKind kind; // to simplify caller's life | |
c99de607 | 103 | }; |
774c051c | 104 | |
c99de607 | 105 | // varios Transfer-* lists |
c2f1edbd | 106 | struct Transfers { |
c99de607 | 107 | TransferList preview; |
108 | TransferList ignore; | |
109 | TransferList complete; | |
110 | TransferList *byDefault; // Transfer-X that has '*' | |
111 | } theTransfers; | |
774c051c | 112 | |
8eeb99bf | 113 | int theTTL; |
114 | time_t theTimestamp; | |
774c051c | 115 | |
774c051c | 116 | private: |
117 | void cfgMethod(ICAP::Method m); | |
118 | void cfgIntHeader(const HttpHeader *h, const char *fname, int &value); | |
c99de607 | 119 | void cfgTransferList(const HttpHeader *h, TransferList &l); |
774c051c | 120 | }; |
121 | ||
122 | ||
123 | ||
008bb7a0 AJ |
124 | |
125 | } // namespace Icap | |
126 | } // namespace Adaptation | |
127 | ||
774c051c | 128 | #endif /* SQUID_ICAPOPTIONS_H */ |