Squid Web Cache master
Loading...
Searching...
No Matches
RegisteredHeaders.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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_HTTP_REGISTEREDHEADERS_H
10#define SQUID_SRC_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 */
122 enumEnd_ // internal tag for end-of-headers
124
126enum class HdrFieldType {
127 ftInvalid,
128 ftInt,
129 ftInt64,
130 ftStr,
132 ftETag,
133 ftPCc,
135 ftPRange,
136 ftPSc,
138};
139
141 None = 0,
144 ReplyHeader = 1 << 2,
146 Denied304Header = 1 << 4, //see comment in HttpReply.cc for meaning
150
151/* POD for HeaderTable */
153public:
154 HeaderTableRecord() = default;
155 HeaderTableRecord(const char *n);
156 HeaderTableRecord(const char *, Http::HdrType, Http::HdrFieldType, int /* HdrKind */);
157
158 const char *name = "";
161 // flags set by constructor from HdrKind parameter
162 bool list = false;;
163 bool request = false;
164 bool reply = false;
165 bool hopbyhop = false;
166 bool denied304 = false;
167};
168
178public:
181 const HeaderTableRecord& lookup (const char *buf, const std::size_t len) const;
183 const HeaderTableRecord& lookup (const std::string &key) const {
184 return lookup(key.data(), key.length());
185 }
187 const HeaderTableRecord& lookup (const SBuf &key) const {
188 return lookup(key.rawContent(), key.length());
189 }
192 return *(idCache[static_cast<int>(id)]);
193 }
194
195private:
196 void initCache();
197 std::vector<const HeaderTableRecord *> idCache;
199};
201
203inline bool
208
210inline bool
212{
213 return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::BAD_HDR);
214}
215
218inline bool
220{
221 return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::OTHER);
222}
223
224std::ostream &operator <<(std::ostream &, HdrType);
225
226}; /* namespace Http */
227
228#endif /* SQUID_SRC_HTTP_REGISTEREDHEADERS_H */
229
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
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:419
Definition forward.h:18
std::ostream & operator<<(std::ostream &, const TunnelerAnswer &)
bool any_registered_header(const Http::HdrType id)
@ PROXY_AUTHENTICATION_INFO
@ IF_UNMODIFIED_SINCE
@ AUTHENTICATION_INFO
@ PROXY_AUTHORIZATION
@ UNLESS_MODIFIED_SINCE
@ CONTENT_DISPOSITION
@ IF_MODIFIED_SINCE
@ TRANSFER_ENCODING
@ SURROGATE_CAPABILITY
@ HDR_X_ACCELERATOR_VARY
@ ALTERNATE_PROTOCOL
@ PROXY_AUTHENTICATE
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