Options.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
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_ICAPOPTIONS_H */
104 
static void Get(ServiceRep::Pointer &service, GetCallback *cb, void *data)
void parse(const String &buf, bool &foundStar)
Definition: Options.cc:209
void configure(const HttpReply *reply)
Definition: Options.cc:85
Definition: SBuf.h:87
time_t expire() const
Definition: Options.cc:79
const char * error
Definition: Options.h:48
void cfgTransferList(const HttpHeader *h, TransferList &l)
Definition: Options.cc:157
void report(int level, const char *prefix) const
Definition: Options.cc:227
bool valid() const
Definition: Options.cc:63
void const char HLPCB void * data
Definition: stub_helper.cc:16
struct Adaptation::Icap::Options::Transfers theTransfers
bool matches(const SBuf &urlPath) const
Definition: Options.cc:188
TransferKind transferKind(const SBuf &urlPath) const
Definition: Options.cc:47
void const char * buf
Definition: stub_helper.cc:16
void GetCallback(void *data, Options *options)
Definition: Options.h:29
bool fresh() const
Definition: Options.cc:68
void cfgMethod(ICAP::Method m)
Definition: Options.cc:138
std::vector< ICAP::Method > methods
Definition: Options.h:51
void cfgIntHeader(const HttpHeader *h, const char *fname, int &value)
Definition: Options.cc:145
time_t timestamp() const
Definition: Options.h:42
void add(const char *extension)
Definition: Options.cc:183

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors