]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Answer.h
Merged from trunk (r12732, v3.3.3+).
[thirdparty/squid.git] / src / adaptation / Answer.h
1 #ifndef SQUID_ADAPTATION__ANSWER_H
2 #define SQUID_ADAPTATION__ANSWER_H
3
4 #include "adaptation/forward.h"
5 #include "HttpMsg.h"
6
7 #include <iosfwd>
8
9 namespace Adaptation
10 {
11
12 /// summarizes adaptation service answer for the noteAdaptationAnswer() API
13 class Answer
14 {
15 public:
16 /// helps interpret other members without a class hierarchy
17 typedef enum {
18 akForward, ///< forward the supplied adapted HTTP message
19 akBlock, ///< block or deny the master xaction; see authority
20 akError, ///< no adapted message will come; see bypassable
21 } Kind;
22
23 static Answer Error(bool final); ///< create an akError answer
24 static Answer Forward(HttpMsg *aMsg); ///< create an akForward answer
25 static Answer Block(const String &aRule); ///< create an akBlock answer
26
27 std::ostream &print(std::ostream &os) const;
28
29 public:
30 HttpMsg::Pointer message; ///< HTTP request or response to forward
31 String ruleId; ///< ACL (or similar rule) name that blocked forwarding
32 bool final; ///< whether the error, if any, cannot be bypassed
33 Kind kind; ///< the type of the answer
34
35 private:
36 explicit Answer(Kind aKind); ///< use static creators instead
37 };
38
39 inline
40 std::ostream &operator <<(std::ostream &os, const Answer &answer)
41 {
42 return answer.print(os);
43 }
44
45 } // namespace Adaptation
46
47 #endif /* SQUID_ADAPTATION__ANSWER_H */