]>
Commit | Line | Data |
---|---|---|
528b2c61 | 1 | |
2 | /* | |
47f6e231 | 3 | * $Id: HttpReply.h,v 1.21 2007/08/13 17:20:51 hno Exp $ |
528b2c61 | 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_HTTPREPLY_H | |
35 | #define SQUID_HTTPREPLY_H | |
36 | ||
8596962e | 37 | #include "HttpMsg.h" |
450e0c10 | 38 | #include "HttpStatusLine.h" |
528b2c61 | 39 | |
528b2c61 | 40 | extern void httpReplyInitModule(void); |
528b2c61 | 41 | /* do everything in one call: init, set, pack, clean, return MemBuf */ |
47f6e231 | 42 | extern MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires); |
528b2c61 | 43 | |
924f73bc | 44 | /* Sync changes here with HttpReply.cc */ |
45 | ||
46 | class HttpHdrContRange; | |
47 | ||
25b6a907 | 48 | class HttpHdrSc; |
49 | ||
8596962e | 50 | class HttpReply: public HttpMsg |
924f73bc | 51 | { |
52 | ||
53 | public: | |
b001e822 | 54 | MEMPROXY_CLASS(HttpReply); |
75faaa7a | 55 | HttpReply(); |
06a5ae20 | 56 | ~HttpReply(); |
8596962e | 57 | |
58 | virtual void reset(); | |
59 | ||
6dd9f4bd | 60 | // use HTTPMSGLOCK() instead of calling this directly |
61 | virtual HttpReply *_lock() | |
4a56ee8d | 62 | { |
6dd9f4bd | 63 | return static_cast<HttpReply*>(HttpMsg::_lock()); |
64 | }; | |
4a56ee8d | 65 | |
66 | //virtual void unlock(); // only needed for debugging | |
67 | ||
8596962e | 68 | // returns true on success |
69 | // returns false and sets *error to zero when needs more data | |
70 | // returns false and sets *error to a positive http_status code on error | |
71 | virtual bool sanityCheckStartLine(MemBuf *buf, http_status *error); | |
924f73bc | 72 | |
73 | /* public, readable; never update these or their .hdr equivalents directly */ | |
924f73bc | 74 | time_t date; |
4a56ee8d | 75 | |
924f73bc | 76 | time_t last_modified; |
4a56ee8d | 77 | |
924f73bc | 78 | time_t expires; |
4a56ee8d | 79 | |
30abd221 | 80 | String content_type; |
4a56ee8d | 81 | |
924f73bc | 82 | HttpHdrSc *surrogate_control; |
4a56ee8d | 83 | |
924f73bc | 84 | HttpHdrContRange *content_range; |
4a56ee8d | 85 | |
924f73bc | 86 | short int keep_alive; |
87 | ||
924f73bc | 88 | /* public, writable, but use httpReply* interfaces when possible */ |
89 | HttpStatusLine sline; | |
4a56ee8d | 90 | |
924f73bc | 91 | HttpBody body; /* for small constant memory-resident text bodies only */ |
8596962e | 92 | |
30abd221 | 93 | String protoPrefix; // e.g., "HTTP/" |
4a56ee8d | 94 | |
06a5ae20 | 95 | bool do_clean; |
8596962e | 96 | |
07947ad8 | 97 | public: |
fb525683 | 98 | virtual int httpMsgParseError(); |
99 | ||
47f6e231 | 100 | virtual bool expectingBody(method_t, int64_t&) const; |
4a56ee8d | 101 | |
06a5ae20 | 102 | void updateOnNotModified(HttpReply const *other); |
4a56ee8d | 103 | |
06a5ae20 | 104 | /* absorb: copy the contents of a new reply to the old one, destroy new one */ |
105 | void absorb(HttpReply * new_rep); | |
4a56ee8d | 106 | |
06a5ae20 | 107 | /* set commonly used info with one call */ |
108 | void setHeaders(HttpVersion ver, http_status status, | |
47f6e231 | 109 | const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires); |
4a56ee8d | 110 | |
06a5ae20 | 111 | /* mem-pack: returns a ready to use mem buffer with a packed reply */ |
112 | MemBuf *pack(); | |
4a56ee8d | 113 | |
06a5ae20 | 114 | /* construct a 304 reply and return it */ |
115 | HttpReply *make304() const; | |
116 | ||
117 | void redirect(http_status, const char *); | |
4a56ee8d | 118 | |
47f6e231 | 119 | int64_t bodySize(method_t) const; |
4a56ee8d | 120 | |
06a5ae20 | 121 | int validatorsMatch (HttpReply const *other) const; |
4a56ee8d | 122 | |
06a5ae20 | 123 | void packHeadersInto(Packer * p) const; |
124 | ||
125 | private: | |
126 | /* initialize */ | |
127 | void init(); | |
4a56ee8d | 128 | |
06a5ae20 | 129 | void clean(); |
4a56ee8d | 130 | |
06a5ae20 | 131 | void hdrCacheClean(); |
4a56ee8d | 132 | |
06a5ae20 | 133 | void packInto(Packer * p); |
4a56ee8d | 134 | |
06a5ae20 | 135 | /* ez-routines */ |
136 | /* construct 304 reply and pack it into MemBuf, return MemBuf */ | |
137 | MemBuf *packed304Reply(); | |
4a56ee8d | 138 | |
06a5ae20 | 139 | /* header manipulation */ |
140 | time_t hdrExpirationTime(); | |
07947ad8 | 141 | |
8596962e | 142 | protected: |
143 | virtual void packFirstLineInto(Packer * p, bool) const; | |
4a56ee8d | 144 | |
429f7150 | 145 | virtual bool parseFirstLine(const char *start, const char *end); |
4a56ee8d | 146 | |
07947ad8 | 147 | virtual void hdrCacheInit(); |
924f73bc | 148 | }; |
149 | ||
b001e822 | 150 | MEMPROXY_CLASS_INLINE(HttpReply) |
924f73bc | 151 | |
528b2c61 | 152 | #endif /* SQUID_HTTPREPLY_H */ |