Options.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_SRC_ADAPTATION_ICAP_OPTIONS_H
10 #define SQUID_SRC_ADAPTATION_ICAP_OPTIONS_H
11 
13 
14 class HttpHeader;
15 class wordlist;
16 
17 namespace Adaptation
18 {
19 namespace Icap
20 {
21 
22 /* Maintains options supported by a given ICAP service.
23  * See RFC 3507, Section "4.10.2 OPTIONS Response". */
24 
25 class Options
26 {
27 
28 public:
29  typedef void GetCallback(void *data, Options *options);
30  static void Get(ServiceRep::Pointer &service, GetCallback *cb, void *data);
31 
32 public:
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 
45  TransferKind transferKind(const SBuf &urlPath) const;
46 
47 public:
48  const char *error; // human-readable information; set iff !valid()
49 
50  // ICAP server MUST supply this info
51  std::vector<ICAP::Method> methods;
53 
54  // ICAP server MAY supply this info. If not, Squid supplies defaults.
58  bool allow204;
59  bool allow206;
60  int preview;
61 
62 protected:
63  // Transfer-* extension list representation
64  // maintains wordlist and does parsing/matching
66  {
67  public:
68  TransferList();
69  ~TransferList();
70 
71  bool matches(const SBuf &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 {
88  TransferList *byDefault; // Transfer-X that has '*'
89  } theTransfers;
90 
91  int theTTL;
92  time_t theTimestamp;
93 
94 private:
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_SRC_ADAPTATION_ICAP_OPTIONS_H */
104 
void cfgIntHeader(const HttpHeader *h, const char *fname, int &value)
Definition: Options.cc:144
void GetCallback(void *data, Options *options)
Definition: Options.h:29
Definition: SBuf.h:93
std::vector< ICAP::Method > methods
Definition: Options.h:51
time_t expire() const
Definition: Options.cc:78
void parse(const String &buf, bool &foundStar)
Definition: Options.cc:208
void configure(const HttpReply *reply)
Definition: Options.cc:84
TransferKind transferKind(const SBuf &urlPath) const
Definition: Options.cc:46
time_t timestamp() const
Definition: Options.h:42
const char * error
Definition: Options.h:48
static void Get(ServiceRep::Pointer &service, GetCallback *cb, void *data)
bool valid() const
Definition: Options.cc:62
void cfgMethod(ICAP::Method m)
Definition: Options.cc:137
void add(const char *extension)
Definition: Options.cc:182
bool matches(const SBuf &urlPath) const
Definition: Options.cc:187
void cfgTransferList(const HttpHeader *h, TransferList &l)
Definition: Options.cc:156
void report(int level, const char *prefix) const
Definition: Options.cc:226
bool fresh() const
Definition: Options.cc:67
struct Adaptation::Icap::Options::Transfers theTransfers

 

Introduction

Documentation

Support

Miscellaneous