3 * $Id: HttpRequest.h,v 1.33 2008/02/26 21:49:34 amosjeffries Exp $
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
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.
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.
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.
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.
34 #ifndef SQUID_HTTPREQUEST_H
35 #define SQUID_HTTPREQUEST_H
38 #include "client_side.h"
39 #include "HierarchyLogEntry.h"
40 #include "HttpRequestMethod.h"
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
);
50 class HttpRequest
: public HttpMsg
54 MEMPROXY_CLASS(HttpRequest
);
56 HttpRequest(const HttpRequestMethod
& aMethod
, protocol_t aProtocol
, const char *aUrlpath
);
60 // use HTTPMSGLOCK() instead of calling this directly
61 virtual HttpRequest
*_lock()
63 return static_cast<HttpRequest
*>(HttpMsg::_lock());
66 void initHTTP(const HttpRequestMethod
& aMethod
, protocol_t aProtocol
, const char *aUrlpath
);
68 /* are responses to this request potentially cachable */
69 bool cacheable() const;
71 /* Now that we care what host contains it is better off being protected. */
72 /* HACK: These two methods are only inline to get around Makefile dependancies */
73 /* caused by HttpRequest being used in places it really shouldn't. */
74 /* ideally they would be methods of URL instead. */
75 inline void SetHost(const char *src
)
79 if( host_addr
.IsAnyAddr() ) {
80 xstrncpy(host
, src
, SQUIDHOSTNAMELEN
);
83 host_addr
.ToHostname(host
, SQUIDHOSTNAMELEN
);
84 debugs(23, 3, "HttpRequest::SetHost() given IP: " << host_addr
);
87 inline const char* GetHost(void) const { return host
; };
95 HttpRequestMethod method
;
97 char login
[MAX_LOGIN_SZ
];
100 char host
[SQUIDHOSTNAMELEN
];
105 AuthUserRequest
*auth_user_request
;
123 IPAddress client_addr
;
125 #if FOLLOW_X_FORWARDED_FOR
126 IPAddress indirect_client_addr
;
127 #endif /* FOLLOW_X_FORWARDED_FOR */
131 HierarchyLogEntry hier
;
135 char *peer_login
; /* Configured peer login:password */
137 time_t lastmod
; /* Used on refreshes */
139 const char *vary_headers
; /* Used when varying entities are detected. Changes how the store key is calculated */
141 char *peer_domain
; /* Configured peer forceddomain */
143 String tag
; /* Internal tag for this request */
145 String extacl_user
; /* User name returned by extacl lookup */
147 String extacl_passwd
; /* Password returned by extacl lookup */
149 String extacl_log
; /* String to be used for access.log purposes */
151 #if FOLLOW_X_FORWARDED_FOR
152 String x_forwarded_for_iterator
; /* XXX a list of IP addresses */
153 #endif /* FOLLOW_X_FORWARDED_FOR */
156 bool multipartRangeRequest() const;
158 bool parseFirstLine(const char *start
, const char *end
);
160 int parseHeader(const char *parse_start
, int len
);
162 virtual bool expectingBody(const HttpRequestMethod
& unused
, int64_t&) const;
164 bool bodyNibbled() const; // the request has a [partially] consumed body
168 void swapOut(StoreEntry
* e
);
170 void pack(Packer
* p
);
172 static void httpRequestPack(void *obj
, Packer
*p
);
174 static HttpRequest
* CreateFromUrlAndMethod(char * url
, const HttpRequestMethod
& method
);
176 static HttpRequest
* CreateFromUrl(char * url
);
179 const char *packableURI(bool full_uri
) const;
182 virtual void packFirstLineInto(Packer
* p
, bool full_uri
) const;
184 virtual bool sanityCheckStartLine(MemBuf
*buf
, http_status
*error
);
186 virtual void hdrCacheInit();
190 MEMPROXY_CLASS_INLINE(HttpRequest
) /**DOCS_NOSEMI*/
192 #endif /* SQUID_HTTPREQUEST_H */