2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
10 #include "RegisteredHeaders.h"
15 * A table with major attributes for every known field.
17 * Invariant on this table:
18 * for each index in headerTable, (int)headerTable[index] = index
20 const HeaderTableRecord headerTable
[] = {
21 {"Accept", Http::HdrType::ACCEPT
, field_type::ftStr
},
22 {"Accept-Charset", Http::HdrType::ACCEPT_CHARSET
, field_type::ftStr
},
23 {"Accept-Encoding", Http::HdrType::ACCEPT_ENCODING
, field_type::ftStr
},
24 {"Accept-Language", Http::HdrType::ACCEPT_LANGUAGE
, field_type::ftStr
},
25 {"Accept-Ranges", Http::HdrType::ACCEPT_RANGES
, field_type::ftStr
},
26 {"Age", Http::HdrType::AGE
, field_type::ftInt
},
27 {"Allow", Http::HdrType::ALLOW
, field_type::ftStr
},
28 {"Alternate-Protocol", Http::HdrType::ALTERNATE_PROTOCOL
, field_type::ftStr
},
29 {"Authentication-Info", Http::HdrType::AUTHENTICATION_INFO
, field_type::ftStr
},
30 {"Authorization", Http::HdrType::AUTHORIZATION
, field_type::ftStr
}, /* for now */
31 {"Cache-Control", Http::HdrType::CACHE_CONTROL
, field_type::ftPCc
},
32 {"Connection", Http::HdrType::CONNECTION
, field_type::ftStr
},
33 {"Content-Base", Http::HdrType::CONTENT_BASE
, field_type::ftStr
},
34 {"Content-Disposition", Http::HdrType::CONTENT_DISPOSITION
, field_type::ftStr
}, /* for now */
35 {"Content-Encoding", Http::HdrType::CONTENT_ENCODING
, field_type::ftStr
},
36 {"Content-Language", Http::HdrType::CONTENT_LANGUAGE
, field_type::ftStr
},
37 {"Content-Length", Http::HdrType::CONTENT_LENGTH
, field_type::ftInt64
},
38 {"Content-Location", Http::HdrType::CONTENT_LOCATION
, field_type::ftStr
},
39 {"Content-MD5", Http::HdrType::CONTENT_MD5
, field_type::ftStr
}, /* for now */
40 {"Content-Range", Http::HdrType::CONTENT_RANGE
, field_type::ftPContRange
},
41 {"Content-Type", Http::HdrType::CONTENT_TYPE
, field_type::ftStr
},
42 {"Cookie", Http::HdrType::COOKIE
, field_type::ftStr
},
43 {"Cookie2", Http::HdrType::COOKIE2
, field_type::ftStr
},
44 {"Date", Http::HdrType::DATE
, field_type::ftDate_1123
},
45 {"ETag", Http::HdrType::ETAG
, field_type::ftETag
},
46 {"Expect", Http::HdrType::EXPECT
, field_type::ftStr
},
47 {"Expires", Http::HdrType::EXPIRES
, field_type::ftDate_1123
},
48 {"Forwarded", Http::HdrType::FORWARDED
, field_type::ftStr
},
49 {"From", Http::HdrType::FROM
, field_type::ftStr
},
50 {"Host", Http::HdrType::HOST
, field_type::ftStr
},
51 {"HTTP2-Settings", Http::HdrType::HTTP2_SETTINGS
, field_type::ftStr
}, /* for now */
52 {"If-Match", Http::HdrType::IF_MATCH
, field_type::ftStr
}, /* for now */
53 {"If-Modified-Since", Http::HdrType::IF_MODIFIED_SINCE
, field_type::ftDate_1123
},
54 {"If-None-Match", Http::HdrType::IF_NONE_MATCH
, field_type::ftStr
}, /* for now */
55 {"If-Range", Http::HdrType::IF_RANGE
, field_type::ftDate_1123_or_ETag
},
56 {"If-Unmodified-Since", Http::HdrType::IF_UNMODIFIED_SINCE
, field_type::ftDate_1123
},
57 {"Keep-Alive", Http::HdrType::KEEP_ALIVE
, field_type::ftStr
},
58 {"Key", Http::HdrType::KEY
, field_type::ftStr
},
59 {"Last-Modified", Http::HdrType::LAST_MODIFIED
, field_type::ftDate_1123
},
60 {"Link", Http::HdrType::LINK
, field_type::ftStr
},
61 {"Location", Http::HdrType::LOCATION
, field_type::ftStr
},
62 {"Max-Forwards", Http::HdrType::MAX_FORWARDS
, field_type::ftInt64
},
63 {"Mime-Version", Http::HdrType::MIME_VERSION
, field_type::ftStr
}, /* for now */
64 {"Negotiate", Http::HdrType::NEGOTIATE
, field_type::ftStr
},
65 {"Origin", Http::HdrType::ORIGIN
, field_type::ftStr
},
66 {"Pragma", Http::HdrType::PRAGMA
, field_type::ftStr
},
67 {"Proxy-Authenticate", Http::HdrType::PROXY_AUTHENTICATE
, field_type::ftStr
},
68 {"Proxy-Authentication-Info", Http::HdrType::PROXY_AUTHENTICATION_INFO
, field_type::ftStr
},
69 {"Proxy-Authorization", Http::HdrType::PROXY_AUTHORIZATION
, field_type::ftStr
},
70 {"Proxy-Connection", Http::HdrType::PROXY_CONNECTION
, field_type::ftStr
},
71 {"Proxy-support", Http::HdrType::PROXY_SUPPORT
, field_type::ftStr
},
72 {"Public", Http::HdrType::PUBLIC
, field_type::ftStr
},
73 {"Range", Http::HdrType::RANGE
, field_type::ftPRange
},
74 {"Referer", Http::HdrType::REFERER
, field_type::ftStr
},
75 {"Request-Range", Http::HdrType::REQUEST_RANGE
, field_type::ftPRange
}, /* usually matches Http::HdrType::RANGE */
76 {"Retry-Afield_type::fter", Http::HdrType::RETRY_AFTER
, field_type::ftStr
}, /* for now (field_type::ftDate_1123 or field_type::ftInt!} */
77 {"Server", Http::HdrType::SERVER
, field_type::ftStr
},
78 {"Set-Cookie", Http::HdrType::SET_COOKIE
, field_type::ftStr
},
79 {"Set-Cookie2", Http::HdrType::SET_COOKIE2
, field_type::ftStr
},
80 {"TE", Http::HdrType::TE
, field_type::ftStr
},
81 {"Title", Http::HdrType::TITLE
, field_type::ftStr
},
82 {"Trailer", Http::HdrType::TRAILER
, field_type::ftStr
},
83 {"Transfer-Encoding", Http::HdrType::TRANSFER_ENCODING
, field_type::ftStr
},
84 {"Translate", Http::HdrType::TRANSLATE
, field_type::ftStr
}, /* for now. may need to crop */
85 {"Unless-Modified-Since", Http::HdrType::UNLESS_MODIFIED_SINCE
, field_type::ftStr
}, /* for now ignore. may need to crop */
86 {"Upgrade", Http::HdrType::UPGRADE
, field_type::ftStr
}, /* for now */
87 {"User-Agent", Http::HdrType::USER_AGENT
, field_type::ftStr
},
88 {"Vary", Http::HdrType::VARY
, field_type::ftStr
}, /* for now */
89 {"Via", Http::HdrType::VIA
, field_type::ftStr
}, /* for now */
90 {"Warning", Http::HdrType::WARNING
, field_type::ftStr
}, /* for now */
91 {"WWW-Authenticate", Http::HdrType::WWW_AUTHENTICATE
, field_type::ftStr
},
92 {"X-Cache", Http::HdrType::X_CACHE
, field_type::ftStr
},
93 {"X-Cache-Lookup", Http::HdrType::X_CACHE_LOOKUP
, field_type::ftStr
},
94 {"X-Forwarded-For", Http::HdrType::X_FORWARDED_FOR
, field_type::ftStr
},
95 {"X-Request-URI", Http::HdrType::X_REQUEST_URI
, field_type::ftStr
},
96 {"X-Squid-Error", Http::HdrType::X_SQUID_ERROR
, field_type::ftStr
},
97 #if X_ACCELERATOR_VARY
98 {"X-Accelerator-Vary", Http::HdrType::HDR_X_ACCELERATOR_VARY
, field_type::ftStr
},
101 {"X-Next-Services", Http::HdrType::X_NEXT_SERVICES
, field_type::ftStr
},
103 {"Surrogate-Capability", Http::HdrType::SURROGATE_CAPABILITY
, field_type::ftStr
},
104 {"Surrogate-Control", Http::HdrType::SURROGATE_CONTROL
, field_type::ftPSc
},
105 {"Front-End-Https", Http::HdrType::FRONT_END_HTTPS
, field_type::ftStr
},
106 {"FTP-Command", Http::HdrType::FTP_COMMAND
, field_type::ftStr
},
107 {"FTP-Arguments", Http::HdrType::FTP_ARGUMENTS
, field_type::ftStr
},
108 {"FTP-Pre", Http::HdrType::FTP_PRE
, field_type::ftStr
},
109 {"FTP-Status", Http::HdrType::FTP_STATUS
, field_type::ftInt
},
110 {"FTP-Reason", Http::HdrType::FTP_REASON
, field_type::ftStr
},
111 {"Other:", Http::HdrType::OTHER
, field_type::ftStr
}, /* ':' will not allow matches */
112 {nullptr, Http::HdrType::ENUM_END
, field_type::ftInvalid
}, /* end of table */
113 {nullptr, Http::HdrType::BAD_HDR
, field_type::ftInvalid
}
116 const LookupTable
<Http::HdrType
, HeaderTableRecord
> HeaderLookupTable(Http::HdrType::BAD_HDR
, headerTable
);
118 extern std::ostream
&
119 operator << (std::ostream
&s
, Http::HdrType id
)
121 // id is guaranteed to be valid by strong type-safety
122 s
<< HeaderById(id
).name
<< '(' << static_cast<int>(id
) << ')';
126 const HeaderTableRecord
&
127 HeaderById(Http::HdrType id
)
129 return headerTable
[static_cast<int>(id
)];