RegisteredHeaders.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_HTTP_REGISTEREDHEADERS_H
10#define SQUID_HTTP_REGISTEREDHEADERS_H
11
12#include "base/LookupTable.h"
13
14#include <iosfwd>
15#include <vector>
16
17namespace Http
18{
21enum HdrType {
22 enumBegin_ = 0, // service value for WholeEnum iteration
23 ACCEPT = enumBegin_, /* MUST BE FIRST */
26 /*ACCEPT_FEATURES,*/ /* RFC 2295 */
50 /*DAV,*/ /* RFC 2518 */
51 /*DEPTH,*/ /* RFC 2518 */
52 /*DERIVED_FROM,*/ /* deprecated RFC 2068 */
53 /*DESTINATION,*/ /* RFC 2518 */
60 /*HTTP2_SETTINGS,*/ /* obsolete RFC 7540 */
61 /*IF,*/ /* RFC 2518 */
72 /*LOCK_TOKEN,*/ /* RFC 2518 */
76 /*OVERWRITE,*/ /* RFC 2518 */
77 ORIGIN, /* CORS Draft specification (see http://www.w3.org/TR/cors/) */
93 /*STATUS_URI,*/ /* RFC 2518 */
94 /*TCN,*/ /* experimental RFC 2295 */
96 /*TIMEOUT,*/ /* RFC 2518 */
97 TITLE, /* obsolete draft suggested header */
104 /*VARIANT_VARY,*/ /* experimental RFC 2295 */
123 enumEnd_ // internal tag for end-of-headers
125
127enum class HdrFieldType {
128 ftInvalid,
129 ftInt,
130 ftInt64,
131 ftStr,
133 ftETag,
134 ftPCc,
136 ftPRange,
137 ftPSc,
139};
140
142 None = 0,
145 ReplyHeader = 1 << 2,
147 Denied304Header = 1 << 4, //see comment in HttpReply.cc for meaning
151
152/* POD for HeaderTable */
154public:
155 HeaderTableRecord() = default;
156 HeaderTableRecord(const char *n);
157 HeaderTableRecord(const char *, Http::HdrType, Http::HdrFieldType, int /* HdrKind */);
158
159 const char *name = "";
162 // flags set by constructor from HdrKind parameter
163 bool list = false;;
164 bool request = false;
165 bool reply = false;
166 bool hopbyhop = false;
167 bool denied304 = false;
168};
169
179public:
182 const HeaderTableRecord& lookup (const char *buf, const std::size_t len) const;
184 const HeaderTableRecord& lookup (const std::string &key) const {
185 return lookup(key.data(), key.length());
186 }
188 const HeaderTableRecord& lookup (const SBuf &key) const {
189 return lookup(key.rawContent(), key.length());
190 }
193 return *(idCache[static_cast<int>(id)]);
194 }
195
196private:
197 void initCache();
198 std::vector<const HeaderTableRecord *> idCache;
200};
202
204inline bool
206{
208}
209
211inline bool
213{
214 return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::BAD_HDR);
215}
216
219inline bool
221{
222 return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::OTHER);
223}
224
225std::ostream &operator <<(std::ostream &, HdrType);
226
227}; /* namespace Http */
228
229#endif /* SQUID_HTTP_REGISTEREDHEADERS_H */
230
static const HeaderTableRecord BadHdr
used to signal "not found" from lookups
const HeaderTableRecord & lookup(Http::HdrType id) const
look record type up by header ID
std::vector< const HeaderTableRecord * > idCache
const HeaderTableRecord & lookup(const std::string &key) const
look record type up by name (std::string)
const HeaderTableRecord & lookup(const SBuf &key) const
look record type up by name (SBuf)
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 with field values defined as #(values) in HTTP/1.1
bool hopbyhop
header is hop by hop
Http::HdrFieldType type
bool denied304
header is not to be updated on receiving a 304 in cache revalidation (see HttpReply....
bool reply
header is a reply header
Definition: SBuf.h:94
const char * rawContent() const
Definition: SBuf.cc:509
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:415
Definition: forward.h:18
std::ostream & operator<<(std::ostream &, const TunnelerAnswer &)
bool any_registered_header(const Http::HdrType id)
@ PROXY_AUTHENTICATION_INFO
@ SURROGATE_CONTROL
@ PROXY_CONNECTION
@ IF_UNMODIFIED_SINCE
@ AUTHENTICATION_INFO
@ CONTENT_LOCATION
@ PROXY_AUTHORIZATION
@ ACCEPT_ENCODING
@ UNLESS_MODIFIED_SINCE
@ WWW_AUTHENTICATE
@ CONTENT_DISPOSITION
@ IF_MODIFIED_SINCE
@ TRANSFER_ENCODING
@ SURROGATE_CAPABILITY
@ ACCEPT_CHARSET
@ HDR_X_ACCELERATOR_VARY
@ ACCEPT_LANGUAGE
@ CONTENT_ENCODING
@ ALTERNATE_PROTOCOL
@ CONTENT_LANGUAGE
@ PROXY_AUTHENTICATE
@ CONTENT_LENGTH
bool any_HdrType_enum_value(const Http::HdrType id)
match any known header type, including OTHER and BAD
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:83

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors