19
18
* it under the terms of the GNU General Public License as published by
20
19
* the Free Software Foundation; either version 2 of the License, or
21
20
* (at your option) any later version.
23
22
* This program is distributed in the hope that it will be useful,
24
23
* but WITHOUT ANY WARRANTY; without even the implied warranty of
25
24
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
25
* GNU General Public License for more details.
28
27
* You should have received a copy of the GNU General Public License
29
28
* along with this program; if not, write to the Free Software
30
29
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34
33
#ifndef SQUID_HTTPHEADER_H
35
34
#define SQUID_HTTPHEADER_H
40
36
/* because we pass a spec by value */
41
37
#include "HttpHeaderRange.h"
42
38
/* HttpHeader holds a HttpHeaderMask */
43
39
#include "HttpHeaderMask.h"
42
/* class forward declarations */
44
class HttpHdrContRange;
45
51
/* constant attributes of http header fields */
47
/* recognized or "known" header fields; @?@ add more! */
53
/** recognized or "known" header fields; @?@ add more! */
87
93
HDR_PROXY_AUTHENTICATION_INFO,
88
94
HDR_PROXY_AUTHORIZATION,
89
95
HDR_PROXY_CONNECTION,
92
HDR_REQUEST_RANGE, /* some clients use this, sigh */
99
HDR_REQUEST_RANGE, /**< some clients use this, sigh */
108
115
HDR_WWW_AUTHENTICATE,
109
116
HDR_AUTHENTICATION_INFO,
111
HDR_X_CACHE_LOOKUP, /* tmp hack, remove later */
118
HDR_X_CACHE_LOOKUP, /**< tmp hack, remove later */
112
119
HDR_X_FORWARDED_FOR,
113
HDR_X_REQUEST_URI, /* appended if ADD_X_REQUEST_URI is #defined */
120
HDR_X_REQUEST_URI, /**< appended if ADD_X_REQUEST_URI is #defined */
114
121
HDR_X_SQUID_ERROR,
116
123
#if X_ACCELERATOR_VARY
117
124
HDR_X_ACCELERATOR_VARY,
119
129
HDR_SURROGATE_CAPABILITY,
120
130
HDR_SURROGATE_CONTROL,
121
131
HDR_FRONT_END_HTTPS,
126
/* possible types for http header fields */
136
/** possible types for http header fields */
128
ftInvalid = HDR_ENUM_END, /* to catch nasty errors with hdr_id<->fld_type clashes */
138
ftInvalid = HDR_ENUM_END, /**< to catch nasty errors with hdr_id<->fld_type clashes */
149
159
} http_hdr_owner_type;
151
struct _HttpHeaderFieldAttrs
161
struct _HttpHeaderFieldAttrs {
153
162
const char *name;
154
163
http_hdr_type id;
160
class HttpHdrContRange;
166
/*iteration for headers; use HttpHeaderPos as opaque type, do not interpret */
168
/** Iteration for headers; use HttpHeaderPos as opaque type, do not interpret */
167
169
typedef ssize_t HttpHeaderPos;
169
171
/* use this and only this to initialize HttpHeaderPos */
172
174
/* these two are defined in structs.h */
176
/// \todo CLEANUP: Kill this.
174
177
typedef struct _TimeOrTag TimeOrTag;
179
/// \todo CLEANUP: Kill this.
176
180
typedef struct _ETag ETag;
178
182
class HttpHeaderEntry
250
254
int hasListMember(http_hdr_type id, const char *member, const char separator) const;
251
255
int hasByNameListMember(const char *name, const char *member, const char separator) const;
252
256
void removeHopByHopEntries();
258
/* protected, do not use these, use interface functions instead */
259
Vector<HttpHeaderEntry *> entries; /**< parsed fields in raw format */
260
HttpHeaderMask mask; /**< bit set <=> entry present */
261
http_hdr_owner_type owner; /**< request or reply */
262
int len; /**< length when packed, not counting terminating null-byte */
265
/** \deprecated Public access replaced by removeHopByHopEntries() */
253
266
void removeConnectionHeaderEntries();
254
/* protected, do not use these, use interface functions instead */
255
Vector<HttpHeaderEntry *> entries; /* parsed fields in raw format */
256
HttpHeaderMask mask; /* bit set <=> entry present */
257
http_hdr_owner_type owner; /* request or reply */
258
int len; /* length when packed, not counting terminating '\0' */
261
269
HttpHeaderEntry *findLastEntry(http_hdr_type id) const;
262
// Make it non-copyable. Our destructor is a bit nasty...
270
/// Made it non-copyable. Our destructor is a bit nasty...
263
271
HttpHeader(const HttpHeader &);
264
272
//assignment is used by the reset method, can't block it..
265
273
//const HttpHeader operator=(const HttpHeader &);
269
extern void httpHeaderRegisterWithCacheManager(CacheManager & manager);
270
277
extern int httpHeaderParseQuotedString (const char *start, String *val);
271
278
SQUIDCEXTERN int httpHeaderHasByNameListMember(const HttpHeader * hdr, const char *name, const char *member, const char separator);
272
279
SQUIDCEXTERN void httpHeaderUpdate(HttpHeader * old, const HttpHeader * fresh, const HttpHeaderMask * denied_mask);