]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpReply.h
2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_HTTPREPLY_H
10 #define SQUID_HTTPREPLY_H
12 #include "http/StatusLine.h"
14 #include "HttpRequest.h"
16 void httpReplyInitModule(void);
18 /* Sync changes here with HttpReply.cc */
20 class HttpHdrContRange
;
24 class HttpReply
: public Http::Message
26 MEMPROXY_CLASS(HttpReply
);
29 typedef RefCount
<HttpReply
> Pointer
;
37 \retval true on success
38 \retval false and sets *error to zero when needs more data
39 \retval false and sets *error to a positive Http::StatusCode on error
41 virtual bool sanityCheckStartLine(const char *buf
, const size_t hdr_len
, Http::StatusCode
*error
);
43 /** \par public, readable; never update these or their .hdr equivalents directly */
52 HttpHdrSc
*surrogate_control
;
54 /// \returns parsed Content-Range for a 206 response and nil for others
55 const HttpHdrContRange
*contentRange() const;
59 /** \par public, writable, but use httpReply* interfaces when possible */
60 Http::StatusLine sline
;
62 HttpBody body
; /**< for small constant memory-resident text bodies only */
64 String protoPrefix
; /**< e.g., "HTTP/" */
69 virtual int httpMsgParseError();
71 virtual bool expectingBody(const HttpRequestMethod
&, int64_t&) const;
73 virtual bool inheritProperties(const Http::Message
*);
75 bool updateOnNotModified(HttpReply
const *other
);
77 /** set commonly used info with one call */
78 void setHeaders(Http::StatusCode status
,
79 const char *reason
, const char *ctype
, int64_t clen
, time_t lmt
, time_t expires
);
81 /** \return a ready to use mem buffer with a packed reply */
84 /** construct a 304 reply and return it */
85 HttpReply
*make304() const;
87 void redirect(Http::StatusCode
, const char *);
89 int64_t bodySize(const HttpRequestMethod
&) const;
91 /** Checks whether received body exceeds known maximum size.
92 * Requires a prior call to calcMaxBodySize().
94 bool receivedBodyTooLarge(HttpRequest
&, int64_t receivedBodySize
);
96 /** Checks whether expected body exceeds known maximum size.
97 * Requires a prior call to calcMaxBodySize().
99 bool expectedBodyTooLarge(HttpRequest
& request
);
101 int validatorsMatch (HttpReply
const *other
) const;
103 void packHeadersInto(Packable
* p
) const;
105 /** Clone this reply.
106 * Could be done as a copy-contructor but we do not want to accidently copy a HttpReply..
108 HttpReply
*clone() const;
110 /// Remove Warnings with warn-date different from Date value
111 void removeStaleWarnings();
113 virtual void hdrCacheInit();
115 /// whether our Date header value is smaller than theirs
116 /// \returns false if any information is missing
117 bool olderThan(const HttpReply
*them
) const;
125 void hdrCacheClean();
127 void packInto(Packable
* p
) const;
130 /** \return construct 304 reply and pack it into a MemBuf */
131 MemBuf
*packed304Reply() const;
133 /* header manipulation */
134 time_t hdrExpirationTime();
136 /** Calculates and stores maximum body size if needed.
137 * Used by receivedBodyTooLarge() and expectedBodyTooLarge().
139 void calcMaxBodySize(HttpRequest
& request
) const;
141 String
removeStaleWarningValues(const String
&value
);
143 mutable int64_t bodySizeMax
; /**< cached result of calcMaxBodySize */
145 HttpHdrContRange
*content_range
; ///< parsed Content-Range; nil for non-206 responses!
148 virtual void packFirstLineInto(Packable
* p
, bool) const { sline
.packInto(p
); }
150 virtual bool parseFirstLine(const char *start
, const char *end
);
153 #endif /* SQUID_HTTPREPLY_H */