RegisteredHeaders.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_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,
47  DATE,
48  /*DAV,*/ /* RFC 2518 */
49  /*DEPTH,*/ /* RFC 2518 */
50  /*DERIVED_FROM,*/ /* deprecated RFC 2068 */
51  /*DESTINATION,*/ /* RFC 2518 */
52  ETAG,
56  FROM,
57  HOST,
59  /*IF,*/ /* RFC 2518 */
66  KEY,
68  LINK,
70  /*LOCK_TOKEN,*/ /* RFC 2518 */
74  /*OVERWRITE,*/ /* RFC 2518 */
75  ORIGIN, /* CORS Draft specification (see http://www.w3.org/TR/cors/) */
90  /*STATUS_URI,*/ /* RFC 2518 */
91  /*TCN,*/ /* experimental RFC 2295 */
92  TE,
93  /*TIMEOUT,*/ /* RFC 2518 */
94  TITLE, /* obsolete draft suggested header */
101  /*VARIANT_VARY,*/ /* experimental RFC 2295 */
103  VIA,
123  enumEnd_ // internal tag for end-of-headers
124 };
125 
127 enum class HdrFieldType {
128  ftInvalid,
129  ftInt,
130  ftInt64,
131  ftStr,
132  ftDate_1123,
133  ftETag,
134  ftPCc,
135  ftPContRange,
136  ftPRange,
137  ftPSc,
139 };
140 
141 enum HdrKind {
142  None = 0,
144  RequestHeader = 1 << 1,
145  ReplyHeader = 1 << 2,
146  HopByHopHeader = 1 << 3,
147  Denied304Header = 1 << 4, //see comment in HttpReply.cc for meaning
150 };
151 
152 /* POD for HeaderTable */
154 public:
156  HeaderTableRecord(const char *n);
157  HeaderTableRecord(const char *, Http::HdrType, Http::HdrFieldType, int /* HdrKind */);
158 
159 public:
160  const char *name;
163  // flags set by constructor from HdrKind parameter
164  bool list;
165  bool request;
166  bool reply;
167  bool hopbyhop;
168  bool denied304;
169 };
170 
180 public:
183  const HeaderTableRecord& lookup (const char *buf, const std::size_t len) const;
185  const HeaderTableRecord& lookup (const std::string &key) const {
186  return lookup(key.data(), key.length());
187  }
189  const HeaderTableRecord& lookup (const SBuf &key) const {
190  return lookup(key.rawContent(), key.length());
191  }
194  return *(idCache[static_cast<int>(id)]);
195  }
196 
197 private:
198  void initCache();
199  std::vector<const HeaderTableRecord *> idCache;
200  static const HeaderTableRecord BadHdr;
201 };
203 
205 inline bool
207 {
208  return (id >= Http::HdrType::enumBegin_ && id < Http::HdrType::enumEnd_);
209 }
210 
212 inline bool
214 {
215  return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::BAD_HDR);
216 }
217 
220 inline bool
222 {
223  return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::OTHER);
224 }
225 
226 }; /* namespace Http */
227 
228 /* ostream output for Http::HdrType */
229 std::ostream &
230 operator<< (std::ostream&, Http::HdrType);
231 
232 #endif /* SQUID_HTTP_REGISTEREDHEADERS_H */
233 
std::vector< const HeaderTableRecord * > idCache
static const HeaderTableRecord BadHdr
used to signal "not found" from lookups
Definition: SBuf.h:87
bool any_HdrType_enum_value(const Http::HdrType id)
match any known header type, including OTHER and BAD
const HeaderTableRecord & lookup(Http::HdrType id) const
look record type up by header ID
bool denied304
header is not to be updated on receiving a 304 in cache revalidation (see HttpReply.cc)
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:405
const HeaderTableRecord & lookup(const std::string &key) const
look record type up by name (std::string)
const HeaderTableRecord & lookup(const char *buf, const std::size_t len) const
look record type up by name (C-string and length)
bool request
header is a request header
bool hopbyhop
header is hop by hop
bool reply
header is a reply header
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
std::ostream & operator<<(std::ostream &, Http::HdrType)
int const char size_t
Definition: stub_liblog.cc:84
bool any_registered_header(const Http::HdrType id)
void const cache_key * key
Http::HdrFieldType type
const HeaderTableRecord & lookup(const SBuf &key) const
look record type up by name (SBuf)
const char * rawContent() const
Definition: SBuf.cc:539
bool list
header with field values defined as #(values) in HTTP/1.1

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors