]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/adaptation/icap/Options.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / adaptation / icap / Options.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#ifndef SQUID_ICAPOPTIONS_H
10#define SQUID_ICAPOPTIONS_H
11
12#include "adaptation/icap/ServiceRep.h"
13
14class HttpHeader;
15class wordlist;
16
17namespace Adaptation
18{
19namespace Icap
20{
21
22/* Maintains options supported by a given ICAP service.
23 * See RFC 3507, Section "4.10.2 OPTIONS Response". */
24
25class Options
26{
27
28public:
29 typedef void GetCallback(void *data, Options *options);
30 static void Get(ServiceRep::Pointer &service, GetCallback *cb, void *data);
31
32public:
33 Options();
34 ~Options();
35
36 void configure(const HttpReply *reply);
37
38 bool valid() const;
39 bool fresh() const;
40 int ttl() const;
41 time_t expire() const;
42 time_t timestamp() const { return theTimestamp; };
43
44 typedef enum { xferNone, xferPreview, xferIgnore, xferComplete } TransferKind;
45 TransferKind transferKind(const String &urlPath) const;
46
47public:
48 const char *error; // human-readable information; set iff !valid()
49
50 // ICAP server MUST supply this info
51 std::vector<ICAP::Method> methods;
52 String istag;
53
54 // ICAP server MAY supply this info. If not, Squid supplies defaults.
55 String service;
56 String serviceId;
57 int max_connections;
58 bool allow204;
59 bool allow206;
60 int preview;
61
62protected:
63 // Transfer-* extension list representation
64 // maintains wordlist and does parsing/matching
65 class TransferList
66 {
67 public:
68 TransferList();
69 ~TransferList();
70
71 bool matches(const String &urlPath) const;
72
73 void parse(const String &buf, bool &foundStar);
74 void add(const char *extension);
75 void report(int level, const char *prefix) const;
76
77 public:
78 wordlist *extensions; // TODO: optimize with a hash of some sort
79 const char *name; // header name, mostly for debugging
80 TransferKind kind; // to simplify caller's life
81 };
82
83 // varios Transfer-* lists
84 struct Transfers {
85 TransferList preview;
86 TransferList ignore;
87 TransferList complete;
88 TransferList *byDefault; // Transfer-X that has '*'
89 } theTransfers;
90
91 int theTTL;
92 time_t theTimestamp;
93
94private:
95 void cfgMethod(ICAP::Method m);
96 void cfgIntHeader(const HttpHeader *h, const char *fname, int &value);
97 void cfgTransferList(const HttpHeader *h, TransferList &l);
98};
99
100} // namespace Icap
101} // namespace Adaptation
102
103#endif /* SQUID_ICAPOPTIONS_H */
104