]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpReply.h
2 * $Id: HttpReply.h,v 1.24 2008/02/26 21:49:34 amosjeffries Exp $
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 #ifndef SQUID_HTTPREPLY_H
33 #define SQUID_HTTPREPLY_H
36 #include "HttpStatusLine.h"
38 extern void httpReplyInitModule(void);
40 /** do everything in one call: init, set, pack, clean, return MemBuf */
41 extern MemBuf
*httpPackedReply(HttpVersion ver
, http_status status
, const char *ctype
, int64_t clen
, time_t lmt
, time_t expires
);
43 /* Sync changes here with HttpReply.cc */
45 class HttpHdrContRange
;
49 class HttpReply
: public HttpMsg
53 MEMPROXY_CLASS(HttpReply
);
59 /// \par use HTTPMSGLOCK() instead of calling this directly
60 virtual HttpReply
*_lock() {
61 return static_cast<HttpReply
*>(HttpMsg::_lock());
64 //virtual void unlock(); // only needed for debugging
67 \retval true on success
68 \retval false and sets *error to zero when needs more data
69 \retval false and sets *error to a positive http_status code on error
71 virtual bool sanityCheckStartLine(MemBuf
*buf
, http_status
*error
);
73 /** \par public, readable; never update these or their .hdr equivalents directly */
82 HttpHdrSc
*surrogate_control
;
84 HttpHdrContRange
*content_range
;
88 /** \par public, writable, but use httpReply* interfaces when possible */
91 HttpBody body
; /**< for small constant memory-resident text bodies only */
93 String protoPrefix
; /**< e.g., "HTTP/" */
98 virtual int httpMsgParseError();
100 virtual bool expectingBody(const HttpRequestMethod
&, int64_t&) const;
102 void updateOnNotModified(HttpReply
const *other
);
104 /** set commonly used info with one call */
105 void setHeaders(HttpVersion ver
, http_status status
,
106 const char *reason
, const char *ctype
, int64_t clen
, time_t lmt
, time_t expires
);
108 /** \return a ready to use mem buffer with a packed reply */
111 /** construct a 304 reply and return it */
112 HttpReply
*make304() const;
114 void redirect(http_status
, const char *);
116 int64_t bodySize(const HttpRequestMethod
&) const;
118 /** Checks whether received body exceeds known maximum size.
119 * Requires a prior call to calcMaxBodySize().
121 bool receivedBodyTooLarge(HttpRequest
&, int64_t receivedBodySize
);
123 /** Checks whether expected body exceeds known maximum size.
124 * Requires a prior call to calcMaxBodySize().
126 bool expectedBodyTooLarge(HttpRequest
& request
);
128 int validatorsMatch (HttpReply
const *other
) const;
130 void packHeadersInto(Packer
* p
) const;
132 /** Clone this reply.
133 * Could be done as a copy-contructor but we do not want to accidently copy a HttpReply..
135 HttpReply
*clone() const;
143 void hdrCacheClean();
145 void packInto(Packer
* p
);
148 /** \return construct 304 reply and pack it into a MemBuf */
149 MemBuf
*packed304Reply();
151 /* header manipulation */
152 time_t hdrExpirationTime();
154 /** Calculates and stores maximum body size if needed.
155 * Used by receivedBodyTooLarge() and expectedBodyTooLarge().
157 void calcMaxBodySize(HttpRequest
& request
);
159 mutable int64_t bodySizeMax
; /**< cached result of calcMaxBodySize */
162 virtual void packFirstLineInto(Packer
* p
, bool) const;
164 virtual bool parseFirstLine(const char *start
, const char *end
);
166 virtual void hdrCacheInit();
169 MEMPROXY_CLASS_INLINE(HttpReply
);
171 #endif /* SQUID_HTTPREPLY_H */