HttpReply.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 #ifndef SQUID_HTTPREPLY_H
10 #define SQUID_HTTPREPLY_H
11 
12 #include "http/StatusLine.h"
13 #include "HttpBody.h"
14 #include "HttpRequest.h"
15 
17 
18 /* Sync changes here with HttpReply.cc */
19 
20 class HttpHdrContRange;
21 
22 class HttpHdrSc;
23 
24 class HttpReply: public Http::Message
25 {
27 
28 public:
30 
31  HttpReply();
32  ~HttpReply();
33 
34  virtual void reset();
35 
36  /* Http::Message API */
37  virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error);
38 
40  time_t date;
41 
42  time_t last_modified;
43 
44  time_t expires;
45 
47 
49 
51  const HttpHdrContRange *contentRange() const;
52 
53  short int keep_alive;
54 
57 
62  bool do_clean;
63 
64 public:
65  virtual int httpMsgParseError();
66 
67  virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const;
68 
69  virtual bool inheritProperties(const Http::Message *);
70 
73  Pointer recreateOnNotModified(const HttpReply &reply304) const;
74 
76  void setHeaders(Http::StatusCode status,
77  const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires);
78 
80  MemBuf *pack() const;
81 
84 
86  HttpReplyPointer make304() const;
87 
88  void redirect(Http::StatusCode, const char *);
89 
90  int64_t bodySize(const HttpRequestMethod&) const;
91 
95  bool receivedBodyTooLarge(HttpRequest&, int64_t receivedBodySize);
96 
101 
102  int validatorsMatch (HttpReply const *other) const;
103 
106  void packHeadersUsingFastPacker(Packable &p) const;
108  void packHeadersUsingSlowPacker(Packable &p) const;
109 
113  HttpReply *clone() const;
114 
116  void removeStaleWarnings();
117 
118  virtual void hdrCacheInit();
119 
122  bool olderThan(const HttpReply *them) const;
123 
126 
129  bool parseHeader(Http1::Parser &hp);
130 
131 private:
133  void init();
134 
135  void clean();
136 
137  void hdrCacheClean();
138 
139  void packInto(MemBuf &) const;
140 
141  /* ez-routines */
143  MemBuf *packed304Reply() const;
144 
145  /* header manipulation */
146  time_t hdrExpirationTime();
147 
151  void calcMaxBodySize(HttpRequest& request) const;
152 
153  String removeStaleWarningValues(const String &value);
154 
155  mutable int64_t bodySizeMax;
158 
159 protected:
160  virtual void packFirstLineInto(Packable * p, bool) const { sline.packInto(p); }
161 
162  virtual bool parseFirstLine(const char *start, const char *end);
163 };
164 
165 #endif /* SQUID_HTTPREPLY_H */
166 
HttpReplyPointer make304() const
Definition: HttpReply.cc:128
String content_type
Definition: HttpReply.h:46
bool expectedBodyTooLarge(HttpRequest &request)
Definition: HttpReply.cc:525
RefCount< HttpReply > Pointer
Definition: HttpReply.h:26
common parts of HttpRequest and HttpReply
Definition: Message.h:26
bool do_clean
Definition: HttpReply.h:62
time_t hdrExpirationTime()
Definition: HttpReply.cc:281
int64_t bodySizeMax
Definition: HttpReply.h:155
virtual int httpMsgParseError()
Definition: HttpReply.cc:475
~HttpReply()
Definition: HttpReply.cc:43
String removeStaleWarningValues(const String &value)
Definition: HttpReply.cc:619
void error(char *format,...)
int64_t bodySize(const HttpRequestMethod &) const
Definition: HttpReply.cc:375
virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error)
Definition: HttpReply.cc:400
void packInto(Packable *) const
pack fields into a Packable object
Definition: StatusLine.cc:50
void packHeadersUsingSlowPacker(Packable &p) const
same as packHeadersUsingFastPacker() but assumes that p cannot quickly process small additions
Definition: HttpReply.cc:94
Http::StatusLine sline
Definition: HttpReply.h:56
time_t last_modified
Definition: HttpReply.h:42
StatusCode
Definition: StatusCode.h:20
void calcMaxBodySize(HttpRequest &request) const
Definition: HttpReply.cc:546
MemBuf * packed304Reply() const
Definition: HttpReply.cc:157
void packHeadersUsingFastPacker(Packable &p) const
Definition: HttpReply.cc:86
HttpReply * clone() const
Definition: HttpReply.cc:573
HttpBody body
Definition: HttpReply.h:58
virtual void packFirstLineInto(Packable *p, bool) const
Definition: HttpReply.h:160
void removeIrrelevantContentLength()
Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2).
Definition: HttpReply.cc:672
virtual bool expectingBody(const HttpRequestMethod &, int64_t &) const
Definition: HttpReply.cc:488
time_t expires
Definition: HttpReply.h:44
MemBuf * pack() const
Definition: HttpReply.cc:111
Definition: MemBuf.h:24
virtual bool inheritProperties(const Http::Message *)
Definition: HttpReply.cc:589
void init()
Definition: HttpReply.cc:50
void redirect(Http::StatusCode, const char *)
Definition: HttpReply.cc:203
bool olderThan(const HttpReply *them) const
Definition: HttpReply.cc:664
void packInto(MemBuf &) const
Definition: HttpReply.cc:103
time_t date
Definition: HttpReply.h:40
bool receivedBodyTooLarge(HttpRequest &, int64_t receivedBodySize)
Definition: HttpReply.cc:517
bool parseHeader(Http1::Parser &hp)
parses reply header using Parser
Definition: HttpReply.cc:467
int validatorsMatch(HttpReply const *other) const
Definition: HttpReply.cc:221
String protoPrefix
Definition: HttpReply.h:60
void clean()
Definition: HttpReply.cc:72
#define MEMPROXY_CLASS(CLASS)
const HttpHdrContRange * contentRange() const
Definition: HttpReply.cc:343
virtual void configureContentLengthInterpreter(Http::ContentLengthInterpreter &)
configures the interpreter as needed
Definition: HttpReply.cc:461
void hdrCacheClean()
Definition: HttpReply.cc:351
static HttpReplyPointer MakeConnectionEstablished()
construct and return an HTTP/200 (Connection Established) response
Definition: HttpReply.cc:120
HttpHdrSc * surrogate_control
Definition: HttpReply.h:48
HttpHdrContRange * content_range
parsed Content-Range; nil for non-206 responses!
Definition: HttpReply.h:157
virtual void reset()
Definition: HttpReply.cc:58
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
Definition: HttpReply.cc:168
void httpReplyInitModule(void)
virtual bool parseFirstLine(const char *start, const char *end)
Definition: HttpReply.cc:455
virtual void hdrCacheInit()
Definition: HttpReply.cc:319
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
short int keep_alive
Definition: HttpReply.h:53
void const char * buf
Definition: stub_helper.cc:16
void removeStaleWarnings()
Remove Warnings with warn-date different from Date value.
Definition: HttpReply.cc:599
Pointer recreateOnNotModified(const HttpReply &reply304) const
Definition: HttpReply.cc:263

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors