HttpReply.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
21
22class HttpHdrSc;
23
25{
27
28public:
30
31 HttpReply();
32 ~HttpReply() override;
33
34 void reset() override;
35
36 /* Http::Message API */
37 bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error) override;
38
40 time_t date;
41
43
44 time_t expires;
45
47
49
51 const HttpHdrContRange *contentRange() const;
52
53 short int keep_alive;
54
57
63
64public:
65 int httpMsgParseError() override;
66
67 bool expectingBody(const HttpRequestMethod&, int64_t&) const override;
68
69 bool inheritProperties(const Http::Message *) override;
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
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
100 bool expectedBodyTooLarge(HttpRequest& request);
101
102 int validatorsMatch (HttpReply const *other) const;
103
109
113 HttpReply *clone() const override;
114
115 void hdrCacheInit() override;
116
119 bool olderThan(const HttpReply *them) const;
120
123
126 bool parseHeader(Http1::Parser &hp);
127
133 size_t parseTerminatedPrefix(const char *, size_t);
134
137 size_t prefixLen() const;
138
139private:
141 void init();
142
143 void clean();
144
145 void hdrCacheClean();
146
147 void packInto(MemBuf &) const;
148
149 /* ez-routines */
151 MemBuf *packed304Reply() const;
152
153 /* header manipulation */
154 time_t hdrExpirationTime();
155
159 void calcMaxBodySize(HttpRequest& request) const;
160
161 mutable int64_t bodySizeMax;
164
165protected:
166 void packFirstLineInto(Packable * p, bool) const override { sline.packInto(p); }
167
168 bool parseFirstLine(const char *start, const char *end) override;
169};
170
171#endif /* SQUID_HTTPREPLY_H */
172
void httpReplyInitModule(void)
void error(char *format,...)
bool parseFirstLine(const char *start, const char *end) override
Definition: HttpReply.cc:457
Http::StatusLine sline
Definition: HttpReply.h:56
size_t parseTerminatedPrefix(const char *, size_t)
Definition: HttpReply.cc:463
String content_type
Definition: HttpReply.h:46
void hdrCacheClean()
Definition: HttpReply.cc:353
MemBuf * pack() const
Definition: HttpReply.cc:112
time_t hdrExpirationTime()
Definition: HttpReply.cc:283
time_t last_modified
Definition: HttpReply.h:42
HttpHdrContRange * content_range
parsed Content-Range; nil for non-206 responses!
Definition: HttpReply.h:163
const HttpHdrContRange * contentRange() const
Definition: HttpReply.cc:345
int httpMsgParseError() override
Definition: HttpReply.cc:515
void configureContentLengthInterpreter(Http::ContentLengthInterpreter &) override
configures the interpreter as needed
Definition: HttpReply.cc:501
HttpReplyPointer make304() const
Definition: HttpReply.cc:129
bool olderThan(const HttpReply *them) const
Definition: HttpReply.cc:640
bool expectingBody(const HttpRequestMethod &, int64_t &) const override
Definition: HttpReply.cc:528
bool parseHeader(Http1::Parser &hp)
parses reply header using Parser
Definition: HttpReply.cc:507
HttpHdrSc * surrogate_control
Definition: HttpReply.h:48
void packFirstLineInto(Packable *p, bool) const override
Definition: HttpReply.h:166
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
Definition: HttpReply.cc:170
void init()
Definition: HttpReply.cc:51
MEMPROXY_CLASS(HttpReply)
RefCount< HttpReply > Pointer
Definition: HttpReply.h:29
bool inheritProperties(const Http::Message *) override
Definition: HttpReply.cc:629
void calcMaxBodySize(HttpRequest &request) const
Definition: HttpReply.cc:586
int64_t bodySize(const HttpRequestMethod &) const
Definition: HttpReply.cc:377
size_t prefixLen() const
Definition: HttpReply.cc:495
MemBuf * packed304Reply() const
Definition: HttpReply.cc:159
HttpBody body
Definition: HttpReply.h:58
int64_t bodySizeMax
Definition: HttpReply.h:161
void removeIrrelevantContentLength()
Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2).
Definition: HttpReply.cc:648
bool receivedBodyTooLarge(HttpRequest &, int64_t receivedBodySize)
Definition: HttpReply.cc:557
void redirect(Http::StatusCode, const char *)
Definition: HttpReply.cc:205
bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error) override
Definition: HttpReply.cc:402
int validatorsMatch(HttpReply const *other) const
Definition: HttpReply.cc:223
void hdrCacheInit() override
Definition: HttpReply.cc:321
void reset() override
Definition: HttpReply.cc:59
void packHeadersUsingSlowPacker(Packable &p) const
same as packHeadersUsingFastPacker() but assumes that p cannot quickly process small additions
Definition: HttpReply.cc:95
~HttpReply() override
Definition: HttpReply.cc:44
bool do_clean
Definition: HttpReply.h:62
void packInto(MemBuf &) const
Definition: HttpReply.cc:104
void packHeadersUsingFastPacker(Packable &p) const
Definition: HttpReply.cc:87
Pointer recreateOnNotModified(const HttpReply &reply304) const
Definition: HttpReply.cc:265
void clean()
Definition: HttpReply.cc:73
bool expectedBodyTooLarge(HttpRequest &request)
Definition: HttpReply.cc:565
time_t date
Definition: HttpReply.h:40
HttpReply * clone() const override
Definition: HttpReply.cc:613
static HttpReplyPointer MakeConnectionEstablished()
construct and return an HTTP/200 (Connection Established) response
Definition: HttpReply.cc:121
String protoPrefix
Definition: HttpReply.h:60
short int keep_alive
Definition: HttpReply.h:53
time_t expires
Definition: HttpReply.h:44
common parts of HttpRequest and HttpReply
Definition: Message.h:26
void packInto(Packable *) const
pack fields into a Packable object
Definition: StatusLine.cc:86
Definition: MemBuf.h:24
StatusCode
Definition: StatusCode.h:20

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors