RegisteredHeaders.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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_HTTP_REGISTEREDHEADERS_H
10 #define SQUID_HTTP_REGISTEREDHEADERS_H
11 
12 #include "base/LookupTable.h"
13 
14 #include <iosfwd>
15 #include <vector>
16 
17 namespace Http
18 {
21 enum HdrType {
22  enumBegin_ = 0, // service value for WholeEnum iteration
23  ACCEPT = enumBegin_, /* MUST BE FIRST */
26  /*ACCEPT_FEATURES,*/ /* RFC 2295 */
29  AGE,
48  DATE,
49  /*DAV,*/ /* RFC 2518 */
50  /*DEPTH,*/ /* RFC 2518 */
51  /*DERIVED_FROM,*/ /* deprecated RFC 2068 */
52  /*DESTINATION,*/ /* RFC 2518 */
53  ETAG,
57  FROM,
58  HOST,
60  /*IF,*/ /* RFC 2518 */
67  KEY,
69  LINK,
71  /*LOCK_TOKEN,*/ /* RFC 2518 */
75  /*OVERWRITE,*/ /* RFC 2518 */
76  ORIGIN, /* CORS Draft specification (see http://www.w3.org/TR/cors/) */
91  /*STATUS_URI,*/ /* RFC 2518 */
92  /*TCN,*/ /* experimental RFC 2295 */
93  TE,
94  /*TIMEOUT,*/ /* RFC 2518 */
95  TITLE, /* obsolete draft suggested header */
102  /*VARIANT_VARY,*/ /* experimental RFC 2295 */
104  VIA,
124  enumEnd_ // internal tag for end-of-headers
125 };
126 
128 enum class HdrFieldType {
129  ftInvalid,
130  ftInt,
131  ftInt64,
132  ftStr,
133  ftDate_1123,
134  ftETag,
135  ftPCc,
136  ftPContRange,
137  ftPRange,
138  ftPSc,
140 };
141 
142 enum HdrKind {
143  None = 0,
145  RequestHeader = 1 << 1,
146  ReplyHeader = 1 << 2,
147  HopByHopHeader = 1 << 3,
148  Denied304Header = 1 << 4, //see comment in HttpReply.cc for meaning
151 };
152 
153 /* POD for HeaderTable */
155 public:
157  HeaderTableRecord(const char *n);
158  HeaderTableRecord(const char *, Http::HdrType, Http::HdrFieldType, int /* HdrKind */);
159 
160 public:
161  const char *name;
164  // flags set by constructor from HdrKind parameter
165  bool list;
166  bool request;
167  bool reply;
168  bool hopbyhop;
169  bool denied304;
170 };
171 
181 public:
184  const HeaderTableRecord& lookup (const char *buf, const std::size_t len) const;
186  const HeaderTableRecord& lookup (const std::string &key) const {
187  return lookup(key.data(), key.length());
188  }
190  const HeaderTableRecord& lookup (const SBuf &key) const {
191  return lookup(key.rawContent(), key.length());
192  }
195  return *(idCache[static_cast<int>(id)]);
196  }
197 
198 private:
199  void initCache();
200  std::vector<const HeaderTableRecord *> idCache;
201  static const HeaderTableRecord BadHdr;
202 };
204 
206 inline bool
208 {
209  return (id >= Http::HdrType::enumBegin_ && id < Http::HdrType::enumEnd_);
210 }
211 
213 inline bool
215 {
216  return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::BAD_HDR);
217 }
218 
221 inline bool
223 {
224  return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::OTHER);
225 }
226 
227 }; /* namespace Http */
228 
229 /* ostream output for Http::HdrType */
230 std::ostream &
231 operator<< (std::ostream&, Http::HdrType);
232 
233 #endif /* SQUID_HTTP_REGISTEREDHEADERS_H */
234 
std::vector< const HeaderTableRecord * > idCache
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:404
static const HeaderTableRecord BadHdr
used to signal "not found" from lookups
Definition: SBuf.h:86
bool any_HdrType_enum_value(const Http::HdrType id)
match any known header type, including OTHER and BAD
bool denied304
header is not to be updated on receiving a 304 in cache revalidation (see HttpReply.cc)
const HeaderTableRecord & lookup(Http::HdrType id) const
look record type up by header ID
std::ostream & operator<<(std::ostream &, const Http::TunnelerAnswer &)
bool request
header is a request header
bool hopbyhop
header is hop by hop
const HeaderTableRecord & lookup(const std::string &key) const
look record type up by name (std::string)
bool reply
header is a reply header
const HeaderTableRecord & lookup(const SBuf &key) const
look record type up by name (SBuf)
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
void const char * buf
Definition: stub_helper.cc:16
const HeaderLookupTable_t HeaderLookupTable
bool any_valid_header(const Http::HdrType id)
match any valid header type, including OTHER but not BAD
int const char size_t
Definition: stub_liblog.cc:86
bool any_registered_header(const Http::HdrType id)
Http::HdrFieldType type
Definition: forward.h:21
bool list
header with field values defined as #(values) in HTTP/1.1
const char * rawContent() const
Definition: SBuf.cc:519

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors