~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/HttpReply.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2010-05-04 11:15:49 UTC
  • mfrom: (1.3.1 upstream)
  • mto: (20.3.1 squeeze) (21.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20100504111549-1apjh2g5sndki4te
Tags: upstream-3.1.3
ImportĀ upstreamĀ versionĀ 3.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
1
/*
3
 
 * $Id: HttpReply.h,v 1.21 2007/08/13 17:20:51 hno Exp $
 
2
 * $Id$
4
3
 *
5
4
 *
6
5
 * SQUID Web Proxy Cache          http://www.squid-cache.org/
19
18
 *  it under the terms of the GNU General Public License as published by
20
19
 *  the Free Software Foundation; either version 2 of the License, or
21
20
 *  (at your option) any later version.
22
 
 *  
 
21
 *
23
22
 *  This program is distributed in the hope that it will be useful,
24
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
25
 *  GNU General Public License for more details.
27
 
 *  
 
26
 *
28
27
 *  You should have received a copy of the GNU General Public License
29
28
 *  along with this program; if not, write to the Free Software
30
29
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31
30
 *
32
31
 */
33
 
 
34
32
#ifndef SQUID_HTTPREPLY_H
35
33
#define SQUID_HTTPREPLY_H
36
34
 
38
36
#include "HttpStatusLine.h"
39
37
 
40
38
extern void httpReplyInitModule(void);
41
 
/* do everything in one call: init, set, pack, clean, return MemBuf */
 
39
 
 
40
#if DEAD_CODE
 
41
/** do everything in one call: init, set, pack, clean, return MemBuf */
42
42
extern MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires);
 
43
#endif
43
44
 
44
45
/* Sync changes here with HttpReply.cc */
45
46
 
57
58
 
58
59
    virtual void reset();
59
60
 
60
 
    // use HTTPMSGLOCK() instead of calling this directly
61
 
    virtual HttpReply *_lock()
62
 
    {
 
61
    /// \par use HTTPMSGLOCK() instead of calling this directly
 
62
    virtual HttpReply *_lock() {
63
63
        return static_cast<HttpReply*>(HttpMsg::_lock());
64
64
    };
65
65
 
66
66
    //virtual void unlock();  // only needed for debugging
67
67
 
68
 
    // returns true on success
69
 
    // returns false and leaves *error unchanged when needs more data
70
 
    // returns false and sets *error to a positive http_status code on error
 
68
    /**
 
69
     \retval true on success
 
70
     \retval false and sets *error to zero when needs more data
 
71
     \retval false and sets *error to a positive http_status code on error
 
72
     */
71
73
    virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error);
72
74
 
73
 
    /* public, readable; never update these or their .hdr equivalents directly */
 
75
    /** \par public, readable; never update these or their .hdr equivalents directly */
74
76
    time_t date;
75
77
 
76
78
    time_t last_modified;
85
87
 
86
88
    short int keep_alive;
87
89
 
88
 
    /* public, writable, but use httpReply* interfaces when possible */
 
90
    /** \par public, writable, but use httpReply* interfaces when possible */
89
91
    HttpStatusLine sline;
90
92
 
91
 
    HttpBody body;              /* for small constant memory-resident text bodies only */
 
93
    HttpBody body;              /**< for small constant memory-resident text bodies only */
92
94
 
93
 
    String protoPrefix;       // e.g., "HTTP/"
 
95
    String protoPrefix;         /**< e.g., "HTTP/"  */
94
96
 
95
97
    bool do_clean;
96
98
 
97
99
public:
98
100
    virtual int httpMsgParseError();
99
101
 
100
 
    virtual bool expectingBody(method_t, int64_t&) const;
 
102
    virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const;
 
103
 
 
104
    virtual bool inheritProperties(const HttpMsg *aMsg);
101
105
 
102
106
    void updateOnNotModified(HttpReply const *other);
103
107
 
104
 
    /* absorb: copy the contents of a new reply to the old one, destroy new one */
105
 
    void absorb(HttpReply * new_rep);
106
 
 
107
 
    /* set commonly used info with one call */
108
 
    void setHeaders(HttpVersion ver, http_status status,
 
108
    /** set commonly used info with one call */
 
109
    void setHeaders(http_status status,
109
110
                    const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires);
110
111
 
111
 
    /* mem-pack: returns a ready to use mem buffer with a packed reply */
 
112
    /** \return a ready to use mem buffer with a packed reply */
112
113
    MemBuf *pack();
113
114
 
114
 
    /* construct a 304 reply and return it */
 
115
    /** construct a 304 reply and return it */
115
116
    HttpReply *make304() const;
116
117
 
117
118
    void redirect(http_status, const char *);
118
119
 
119
 
    int64_t bodySize(method_t) const;
 
120
    int64_t bodySize(const HttpRequestMethod&) const;
 
121
 
 
122
    /** Checks whether received body exceeds known maximum size.
 
123
     * Requires a prior call to calcMaxBodySize().
 
124
     */
 
125
    bool receivedBodyTooLarge(HttpRequest&, int64_t receivedBodySize);
 
126
 
 
127
    /** Checks whether expected body exceeds known maximum size.
 
128
     * Requires a prior call to calcMaxBodySize().
 
129
     */
 
130
    bool expectedBodyTooLarge(HttpRequest& request);
120
131
 
121
132
    int validatorsMatch (HttpReply const *other) const;
122
133
 
123
134
    void packHeadersInto(Packer * p) const;
124
135
 
125
 
    /// Clone this reply.
126
 
    /// Could be done as a copy-contructor but we do not want to
127
 
    /// accidently copy a HttpReply..
 
136
    /** Clone this reply.
 
137
     *  Could be done as a copy-contructor but we do not want to accidently copy a HttpReply..
 
138
     */
128
139
    HttpReply *clone() const;
129
140
 
130
141
private:
131
 
    /* initialize */
 
142
    /** initialize */
132
143
    void init();
133
144
 
134
145
    void clean();
138
149
    void packInto(Packer * p);
139
150
 
140
151
    /* ez-routines */
141
 
    /* construct 304 reply and pack it into MemBuf, return MemBuf */
 
152
    /** \return construct 304 reply and pack it into a MemBuf */
142
153
    MemBuf *packed304Reply();
143
154
 
144
155
    /* header manipulation */
145
156
    time_t hdrExpirationTime();
146
157
 
 
158
    /** Calculates and stores maximum body size if needed.
 
159
     * Used by receivedBodyTooLarge() and expectedBodyTooLarge().
 
160
     */
 
161
    void calcMaxBodySize(HttpRequest& request);
 
162
 
 
163
    mutable int64_t bodySizeMax; /**< cached result of calcMaxBodySize */
 
164
 
147
165
protected:
148
166
    virtual void packFirstLineInto(Packer * p, bool) const;
149
167
 
152
170
    virtual void hdrCacheInit();
153
171
};
154
172
 
155
 
MEMPROXY_CLASS_INLINE(HttpReply)
 
173
MEMPROXY_CLASS_INLINE(HttpReply);
156
174
 
157
175
#endif /* SQUID_HTTPREPLY_H */