]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpRequest.h
Merge from trunk
[thirdparty/squid.git] / src / HttpRequest.h
1
2 /*
3 * $Id: HttpRequest.h,v 1.33 2008/02/26 21:49:34 amosjeffries Exp $
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 */
33
34 #ifndef SQUID_HTTPREQUEST_H
35 #define SQUID_HTTPREQUEST_H
36
37 #include "HttpMsg.h"
38 #include "client_side.h"
39 #include "HierarchyLogEntry.h"
40 #include "HttpRequestMethod.h"
41
42 /* Http Request */
43 extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection);
44 extern int httpRequestHdrAllowedByName(http_hdr_type id);
45 extern void httpRequestPack(void *obj, Packer *p);
46
47
48 class HttpHdrRange;
49
50 class HttpRequest: public HttpMsg
51 {
52
53 public:
54 MEMPROXY_CLASS(HttpRequest);
55 HttpRequest();
56 HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath);
57 ~HttpRequest();
58 virtual void reset();
59
60 // use HTTPMSGLOCK() instead of calling this directly
61 virtual HttpRequest *_lock()
62 {
63 return static_cast<HttpRequest*>(HttpMsg::_lock());
64 };
65
66 void initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath);
67
68 virtual HttpRequest *clone() const;
69
70 /* are responses to this request potentially cachable */
71 bool cacheable() const;
72
73 /* Now that we care what host contains it is better off being protected. */
74 /* HACK: These two methods are only inline to get around Makefile dependancies */
75 /* caused by HttpRequest being used in places it really shouldn't. */
76 /* ideally they would be methods of URL instead. */
77 inline void SetHost(const char *src)
78 {
79 host_addr.SetEmpty();
80 host_addr = src;
81 if( host_addr.IsAnyAddr() ) {
82 xstrncpy(host, src, SQUIDHOSTNAMELEN);
83 }
84 else {
85 host_addr.ToHostname(host, SQUIDHOSTNAMELEN);
86 debugs(23, 3, "HttpRequest::SetHost() given IP: " << host_addr);
87 }
88 };
89 inline const char* GetHost(void) const { return host; };
90
91 protected:
92 void clean();
93
94 void init();
95
96 public:
97 HttpRequestMethod method;
98
99 char login[MAX_LOGIN_SZ];
100
101 private:
102 char host[SQUIDHOSTNAMELEN];
103
104 /***
105 * The client side connection data of pinned connections for the client side
106 * request related objects
107 */
108 ConnStateData *pinned_connection;
109
110 public:
111 IPAddress host_addr;
112
113 AuthUserRequest *auth_user_request;
114
115 u_short port;
116
117 String urlpath;
118
119 char *canonical;
120
121 request_flags flags;
122
123 HttpHdrRange *range;
124
125 time_t ims;
126
127 int imslen;
128
129 int max_forwards;
130
131 IPAddress client_addr;
132
133 #if FOLLOW_X_FORWARDED_FOR
134 IPAddress indirect_client_addr;
135 #endif /* FOLLOW_X_FORWARDED_FOR */
136
137 IPAddress my_addr;
138
139 HierarchyLogEntry hier;
140
141 err_type errType;
142
143 char *peer_login; /* Configured peer login:password */
144
145 time_t lastmod; /* Used on refreshes */
146
147 const char *vary_headers; /* Used when varying entities are detected. Changes how the store key is calculated */
148
149 char *peer_domain; /* Configured peer forceddomain */
150
151 String tag; /* Internal tag for this request */
152
153 String extacl_user; /* User name returned by extacl lookup */
154
155 String extacl_passwd; /* Password returned by extacl lookup */
156
157 String extacl_log; /* String to be used for access.log purposes */
158
159 #if FOLLOW_X_FORWARDED_FOR
160 String x_forwarded_for_iterator; /* XXX a list of IP addresses */
161 #endif /* FOLLOW_X_FORWARDED_FOR */
162
163 public:
164 bool multipartRangeRequest() const;
165
166 bool parseFirstLine(const char *start, const char *end);
167
168 int parseHeader(const char *parse_start, int len);
169
170 virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;
171
172 bool bodyNibbled() const; // the request has a [partially] consumed body
173
174 int prefixLen();
175
176 void swapOut(StoreEntry * e);
177
178 void pack(Packer * p);
179
180 static void httpRequestPack(void *obj, Packer *p);
181
182 static HttpRequest * CreateFromUrlAndMethod(char * url, const HttpRequestMethod& method);
183
184 static HttpRequest * CreateFromUrl(char * url);
185
186 void setPinnedConnection(ConnStateData *conn) {
187 pinned_connection = cbdataReference(conn);
188 }
189
190 ConnStateData *pinnedConnection() {
191 return pinned_connection;
192 }
193
194 void releasePinnedConnection() {
195 cbdataReferenceDone(pinned_connection);
196 }
197
198 private:
199 const char *packableURI(bool full_uri) const;
200
201 protected:
202 virtual void packFirstLineInto(Packer * p, bool full_uri) const;
203
204 virtual bool sanityCheckStartLine(MemBuf *buf, http_status *error);
205
206 virtual void hdrCacheInit();
207
208 virtual bool inheritProperties(const HttpMsg *aMsg);
209 };
210
211 MEMPROXY_CLASS_INLINE(HttpRequest) /**DOCS_NOSEMI*/
212
213 #endif /* SQUID_HTTPREQUEST_H */