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