]> git.ipfire.org Git - thirdparty/squid.git/blame - src/HttpReply.h
Fix assertion failed: external_acl.cc:908: ch->auth_user_request != NULL
[thirdparty/squid.git] / src / HttpReply.h
CommitLineData
528b2c61 1/*
262a0e14 2 * $Id$
528b2c61 3 *
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
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.
16 *
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.
26ac0430 21 *
528b2c61 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.
26ac0430 26 *
528b2c61 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.
30 *
31 */
528b2c61 32#ifndef SQUID_HTTPREPLY_H
33#define SQUID_HTTPREPLY_H
34
8596962e 35#include "HttpMsg.h"
450e0c10 36#include "HttpStatusLine.h"
528b2c61 37
528b2c61 38extern void httpReplyInitModule(void);
e0459b28 39
11992b6f 40#if DEAD_CODE
e0459b28 41/** do everything in one call: init, set, pack, clean, return MemBuf */
47f6e231 42extern MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires);
11992b6f 43#endif
528b2c61 44
924f73bc 45/* Sync changes here with HttpReply.cc */
46
47class HttpHdrContRange;
48
25b6a907 49class HttpHdrSc;
50
8596962e 51class HttpReply: public HttpMsg
924f73bc 52{
53
54public:
f3630c67
AR
55 typedef HttpMsgPointerT<HttpReply> Pointer;
56
b001e822 57 MEMPROXY_CLASS(HttpReply);
75faaa7a 58 HttpReply();
06a5ae20 59 ~HttpReply();
8596962e 60
61 virtual void reset();
62
e0459b28
AJ
63 /// \par use HTTPMSGLOCK() instead of calling this directly
64 virtual HttpReply *_lock() {
6dd9f4bd 65 return static_cast<HttpReply*>(HttpMsg::_lock());
66 };
4a56ee8d 67
68 //virtual void unlock(); // only needed for debugging
69
e0459b28
AJ
70 /**
71 \retval true on success
72 \retval false and sets *error to zero when needs more data
73 \retval false and sets *error to a positive http_status code on error
74 */
96ee497f 75 virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error);
924f73bc 76
e0459b28 77 /** \par public, readable; never update these or their .hdr equivalents directly */
924f73bc 78 time_t date;
4a56ee8d 79
924f73bc 80 time_t last_modified;
4a56ee8d 81
924f73bc 82 time_t expires;
4a56ee8d 83
30abd221 84 String content_type;
4a56ee8d 85
924f73bc 86 HttpHdrSc *surrogate_control;
4a56ee8d 87
924f73bc 88 HttpHdrContRange *content_range;
4a56ee8d 89
924f73bc 90 short int keep_alive;
91
e0459b28 92 /** \par public, writable, but use httpReply* interfaces when possible */
924f73bc 93 HttpStatusLine sline;
4a56ee8d 94
e0459b28 95 HttpBody body; /**< for small constant memory-resident text bodies only */
8596962e 96
e0459b28 97 String protoPrefix; /**< e.g., "HTTP/" */
4a56ee8d 98
06a5ae20 99 bool do_clean;
8596962e 100
07947ad8 101public:
fb525683 102 virtual int httpMsgParseError();
103
60745f24 104 virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const;
4a56ee8d 105
d67acb4e
AJ
106 virtual bool inheritProperties(const HttpMsg *aMsg);
107
06a5ae20 108 void updateOnNotModified(HttpReply const *other);
4a56ee8d 109
e0459b28 110 /** set commonly used info with one call */
11992b6f 111 void setHeaders(http_status status,
47f6e231 112 const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires);
4a56ee8d 113
e0459b28 114 /** \return a ready to use mem buffer with a packed reply */
06a5ae20 115 MemBuf *pack();
4a56ee8d 116
e0459b28 117 /** construct a 304 reply and return it */
06a5ae20 118 HttpReply *make304() const;
119
120 void redirect(http_status, const char *);
4a56ee8d 121
60745f24 122 int64_t bodySize(const HttpRequestMethod&) const;
4a56ee8d 123
e0459b28
AJ
124 /** Checks whether received body exceeds known maximum size.
125 * Requires a prior call to calcMaxBodySize().
126 */
0667cbfb 127 bool receivedBodyTooLarge(HttpRequest&, int64_t receivedBodySize);
128
e0459b28
AJ
129 /** Checks whether expected body exceeds known maximum size.
130 * Requires a prior call to calcMaxBodySize().
131 */
0667cbfb 132 bool expectedBodyTooLarge(HttpRequest& request);
133
06a5ae20 134 int validatorsMatch (HttpReply const *other) const;
4a56ee8d 135
06a5ae20 136 void packHeadersInto(Packer * p) const;
137
e0459b28
AJ
138 /** Clone this reply.
139 * Could be done as a copy-contructor but we do not want to accidently copy a HttpReply..
140 */
da33c835
HN
141 HttpReply *clone() const;
142
c679653d
AR
143 /// Remove Warnings with warn-date different from Date value
144 void removeStaleWarnings();
145
06a5ae20 146private:
e0459b28 147 /** initialize */
06a5ae20 148 void init();
4a56ee8d 149
06a5ae20 150 void clean();
4a56ee8d 151
06a5ae20 152 void hdrCacheClean();
4a56ee8d 153
06a5ae20 154 void packInto(Packer * p);
4a56ee8d 155
06a5ae20 156 /* ez-routines */
e0459b28 157 /** \return construct 304 reply and pack it into a MemBuf */
06a5ae20 158 MemBuf *packed304Reply();
4a56ee8d 159
06a5ae20 160 /* header manipulation */
161 time_t hdrExpirationTime();
07947ad8 162
e0459b28
AJ
163 /** Calculates and stores maximum body size if needed.
164 * Used by receivedBodyTooLarge() and expectedBodyTooLarge().
165 */
0667cbfb 166 void calcMaxBodySize(HttpRequest& request);
167
c679653d
AR
168 String removeStaleWarningValues(const String &value);
169
e0459b28 170 mutable int64_t bodySizeMax; /**< cached result of calcMaxBodySize */
0667cbfb 171
8596962e 172protected:
173 virtual void packFirstLineInto(Packer * p, bool) const;
4a56ee8d 174
429f7150 175 virtual bool parseFirstLine(const char *start, const char *end);
4a56ee8d 176
07947ad8 177 virtual void hdrCacheInit();
924f73bc 178};
179
e0459b28 180MEMPROXY_CLASS_INLINE(HttpReply);
924f73bc 181
528b2c61 182#endif /* SQUID_HTTPREPLY_H */